摘要:
1 /* 2 * kmp 3 */ 4 5 #include <cstdio> 6 #include <cstring> 7 #include <iostream> 8 9 using namespace std;10 11 const int N = 100005;12 13 int next[N];14 char pat[N];15 16 void indexNext() {17 int k = 0;18 next[1] = 0;19 for (int i=2; pat[i]; ++i) {20 while (k && pat[k+1]! 阅读全文
posted @ 2012-05-07 07:12
Try86
阅读(193)
评论(0)
推荐(0)
摘要:
1 /* 2 * KMP 3 * 思路:把两个串连接,然后求next[]数组值 4 * 注意:当两个串都是重复串且重复子串一样是,要特殊处理 5 */ 6 7 #include <cstdio> 8 #include <iostream> 9 10 using namespace std;11 12 const int N = 50005;13 14 int next[N<<1];15 char str[N<<1], pat[N];16 17 void indexNext() {18 int k = 0;19 next[1] = 0;20 ... 阅读全文
posted @ 2012-05-07 07:01
Try86
阅读(280)
评论(0)
推荐(0)
浙公网安备 33010602011771号