摘要:
最长公共子串 给出两个长度小于1e5的串,求它们的最长公共子串。 当然是用后缀数组辣,把两个串拼起来,中间加个@符号,再求最长重复子串,处理一下即可。 c++ include include include using namespace std; const int maxn=2e5+5; cha 阅读全文
摘要:
poj2406 Power Strings(kmp) 给出一个字符串,问这个字符串是一个字符串重复几次。要求最大化重复次数。 若当前字符串为S,用kmp匹配'\0'+S和S即可。 c++ include include using namespace std; const int maxn=2e6+ 阅读全文
摘要:
看毛片算法 给出两个字符串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]; 阅读全文
摘要:
马拉车算法 给出一个只由小写英文字符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 阅读全文