随笔分类 -  ICPC-模板

摘要:模板 int getMin(char *s) { int i = 0, j = 1, l; int len = strlen(s); while(i < len && j < len) { for(l = 0; l < len; l++) if(s[(i + l) % len] != s[(j + 阅读全文
posted @ 2017-09-26 18:50 qwerity 阅读(710) 评论(0) 推荐(0)
摘要:模板 #include<stdio.h> #include<string.h> #include<algorithm> #include<map> using namespace std; const int maxn = 2e5 + 10; char s[maxn], sNew[maxn<<1]; 阅读全文
posted @ 2017-09-26 18:21 qwerity 阅读(215) 评论(0) 推荐(0)
摘要://截取字符串 ch 的 st~en 这一段子串返回子串的首地址 //注意用完需要根据需要最后free()掉 char* substring(char* ch,int st,int en) { int length = en - st + 1; char* pch=ch; char* subch=( 阅读全文
posted @ 2017-09-23 20:03 qwerity 阅读(162) 评论(0) 推荐(0)
摘要:废话不多说,上模板 #include<bits/stdc++.h> const int maxn = 1e6 + 10; int Next[maxn], extend[maxn], moL, strL;///Next数组、extend数组、模式串长度、母串长度 char mo[maxn], S[ma 阅读全文
posted @ 2017-09-22 16:02 qwerity 阅读(158) 评论(0) 推荐(0)
摘要:经典问题 : 给出一个由某个循环节构成的字符串,要你找出最小的循环节,例如 abababab 最小循环节当是 ab ,而类似 abab 也可以成为它的循环节,但并非最短。 分析 : 对于上述问题有两个结论 如果对于next数组中的 i, 符合 i % ( i - next[i] ) == 0 && 阅读全文
posted @ 2017-09-20 21:56 qwerity 阅读(2413) 评论(0) 推荐(0)
摘要:问题描述 : 在一个给定的无序序列当中找出最长且递增的子序列 (不一定连续) 对于这个经典问题通常有两种时间复杂度不一样方法来解决一个是O(n2)的算法 另外一个是采用了二分或树状数组O(nlogn)的算法。 动态规划 O(n2) 算法 : 对于序列 squ[1]、squ[2]……squ[n] 分别 阅读全文
posted @ 2017-09-13 17:05 qwerity 阅读(461) 评论(0) 推荐(0)
摘要:① 使用增量构造法可以构造出升序数组arr的不重复子集,并且按字典序排序 #include<bits/stdc++.h> using namespace std; int arr[16]; inline void print_subset(int *index, int cur, int n)/// 阅读全文
posted @ 2017-07-11 19:51 qwerity 阅读(1022) 评论(0) 推荐(0)
摘要:求取出现的次数 : #include<bits/stdc++.h> const int maxn = 1e6 + 10; char mo[maxn], str[maxn];///mo为模式串、str为主串 int next[maxn]; inline void GetNext() { int i = 阅读全文
posted @ 2017-05-20 21:01 qwerity 阅读(808) 评论(0) 推荐(0)