
String algorithm
X-Wyatt
For free 邮箱whitezhangv5@gmail.com
展开
-
HDU 2896
#include#include#include#includeusing namespace std;const int maxn = 100008;int sz, ans[8];int arr[maxn], mark[maxn];char ch[508][208];char txt[10008];struct Node{ int count, f原创 2012-10-02 14:45:44 · 435 阅读 · 0 评论 -
KMP算法总结
KMP题目重在理解next数组的含义:next数组的作用 :next[j] 记录模式串中第 j 个字符的最长公共前缀长度(重要,这是它的意义所在) 第二种理解方式,当模式串与主串失配时,跳回的位置。next[len] (即字符串'\0'结束标志的next值):单个字符串匹配时与周期有关原创 2012-09-11 18:48:19 · 448 阅读 · 0 评论 -
POJ 2752
KMP#include #include #include using namespace std;char b[400005];int next[400005];int n, m;void getnext(){ int j,k; j=0; k=-1; next[0]=-1; while(j<m) { if(原创 2014-04-15 17:13:20 · 892 阅读 · 0 评论