KMP
Jinx_jinx_again
啊啊啊啊哈哈哈
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
HDU 1711 Number Sequence
KMP 在int上的应用~~~刻入灵魂#include #include #include #include using namespace std;int P[10005];int T[1000005];int f[10005];int n,m;void getfail(){ //int m=strlen(P); f[0]=0;f[1]=0;原创 2013-08-09 10:27:23 · 780 阅读 · 0 评论 -
POJ 3450 Corporate Identity
好水好水~~~~ 同上啊同上#include #include #include #include using namespace std;char str[4005][205];char tmp[205],ans[205];int f[205];int n;void getfail(char *P){ int m=strlen(P); f[0]=0原创 2013-08-09 09:23:21 · 751 阅读 · 0 评论 -
hdu 2203 亲和串
把T串扩展成两倍 然后KMP 注意T的长度要大于P的长度#include #include #include #include using namespace std;char P[400005];char T[400005];int f[400005];void getfail(){ int m=strlen(P); f[0]=0;f[1]=0原创 2013-08-09 10:48:47 · 902 阅读 · 0 评论 -
POJ 3080 Blue Jeans (KMP)
求出公共子序列 要求最长 字典序最小枚举第一串的所有子串 然后对每一个串做KMP。找到目标子串学会了 strncpy函数的使用 我已可入灵魂 #include #include #include #include using namespace std;char str[20][70];char tmp[70],ans[70];int f[70];原创 2013-08-09 09:08:36 · 923 阅读 · 0 评论 -
POJ 2752 Seek the Name, Seek the Fame
题意:找到整个串中既是后缀 又是前缀的所有可能的长度思路:先直接找到F[LEN]。然后一直递推下去。翔 见#include #include #include #include using namespace std;char P[400005];int f[400005];void getfail(){ int m=strlen(P); f[0]=原创 2013-08-08 21:55:50 · 907 阅读 · 0 评论 -
POJ 3461 Oulipo
模板题#include #include #include #include using namespace std;char P[1000005];int f[400005];char T[1000005];int ans;void getfail(){ int m=strlen(P); f[0]=0;f[1]=0; for(int i=1;原创 2013-08-08 22:20:16 · 967 阅读 · 0 评论 -
hdu 3336 Count the string
我不是参考这里的,你们不要质疑我。觉得上面说的很好。我只是想加一些自己的思考。DP数组是记录的 以当前位置结尾的。比如 ababab当i=1时 此时就只有 a当i=2时 此时只有 ab 但是ab串中也有a呀 为什么不要 因为上面说的是以 b结尾 所以最后一个一定要是b当i=3时 此时 由 fail 数组可以得到 f【3】=1 也就是第一个a与第二个a原创 2013-08-09 16:31:26 · 952 阅读 · 2 评论
分享