摘要: poj2406 Power Strings(kmp) 给出一个字符串,问这个字符串是一个字符串重复几次。要求最大化重复次数。 若当前字符串为S,用kmp匹配'\0'+S和S即可。 c++ include include using namespace std; const int maxn=2e6+ 阅读全文
posted @ 2018-06-13 21:01 pechpo 阅读(127) 评论(0) 推荐(0)
摘要: 看毛片算法 给出两个字符串s1和s2,其中s2为s1的子串,求出s2在s1中所有出现的位置。$n,m include using namespace std; const int maxn=1e6+5; char s1[maxn], s2[maxn]; int n1, n2, nxt[maxn]; 阅读全文
posted @ 2018-06-13 20:26 pechpo 阅读(707) 评论(0) 推荐(0)
摘要: 马拉车算法 给出一个只由小写英文字符a,b,c...y,z组成的字符串S,求S中最长回文串的长度。字符串长度len include include using namespace std; const int maxn=3e7+5; char s[maxn], s2[maxn]; int n; in 阅读全文
posted @ 2018-06-13 18:54 pechpo 阅读(443) 评论(0) 推荐(0)
摘要: New Distinct Substrings(后缀数组) 给定一个字符串,求不相同的子串的个数。$n include using namespace std; const int maxn=50005; int T, n, m=maxn; char s[maxn]; bool cmp(int r, 阅读全文
posted @ 2018-06-13 14:58 pechpo 阅读(189) 评论(0) 推荐(0)
摘要: poj 1743 Musical Theme(最长重复子串 后缀数组) 有N(1 include include using namespace std; const int maxn=4e4+5; int n, m, a[maxn]; int x, y, t, wa[maxn], wb[maxn] 阅读全文
posted @ 2018-06-13 11:36 pechpo 阅读(156) 评论(0) 推荐(0)