字符串
yerongsc
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
hdu 1358 Period
kmp算法的应用。 kmp算法入门http://billhoo.blog.51cto.com/2337751/411486 字符串偏移量为i-next[i],i为字符串的当前前缀长度。若偏移量能够被前缀长度整除,则该前缀可写为A^B。 #include #include #include using namespace std; void getNext(char *str,int原创 2013-08-03 14:26:41 · 434 阅读 · 0 评论 -
poj 2752 Seek the Name, Seek the Fame
求字符串的前缀和后缀相同的前-后缀长度 kmp算法的应用,求出的next数组即为最长的前缀和后缀相同的前-后缀长度,递归求next数组,直到不存在这样的前后缀,每次得到的数组即为一种满足题意的前后缀长度,数组不包含该字符串本身的长度,即最大的前后缀长度为数组长度。 #include #include #include using namespace std; void getNext(原创 2013-08-03 15:19:36 · 445 阅读 · 0 评论 -
hdu 3374 String Problem
#include #include #include using namespace std; void getNext(char *str,int *next) { int j = 0; int len = strlen(str); next[1] = 0; for(int i = 2;i<len+1;i++) { while(j>0&&str[j]!=str[i-1])原创 2013-08-03 16:54:30 · 430 阅读 · 0 评论 -
hdu 3068 最长回文字串
manacher模板 参见http://www.cnblogs.com/wuyiqi/archive/2012/06/25/2561063.html #include #include #include using namespace std; const int maxN = 110005; char str1[maxN]; char newstr[2*maxN]; int p[2*原创 2013-08-03 18:11:10 · 509 阅读 · 0 评论 -
poj 1226 Substrings
求多个字符串的最长公共字串 利用后缀数组求解,将所有的字符串连接成一个长的字符串,二分所有字符串中最短的字符串的长度mid为公共前缀的长度,求出所有满足公共前缀长度大于等于mid的后缀,判断所有的字符串是否都包含在这些后缀中,都包含,则mid为一个可行的长度。 #include #include #include #include using namespace std; #原创 2013-08-06 12:46:46 · 459 阅读 · 0 评论 -
hdu 1075 What Are You Talking About
trie树,注意处理只是字符串前缀而不是完整的对应关系的情况 #include #include #include using namespace std; const int N = 10000005; struct Trie { int next[30]; char str[15]; }trie[N]; int cnt = 1; v原创 2013-08-24 13:44:03 · 491 阅读 · 0 评论
分享