KMP AC自动机
hr_whisper
来自Fzu12级学生,喜欢编程。
新blog地址: www.hrwhisper.me
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LA 3026 - Period KMP
看题传送门:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1027 给定一个长度为n的循环节,求它的每个前缀的最短循环节。换句话说,对于每个i (21(如果k处在),使得s的前i个字符组成的前缀是某个字符串重复K次得到。输出所有存在K的i原创 2013-10-13 09:33:41 · 1232 阅读 · 0 评论 -
HDU 3746 Cyclic Nacklace KMP
传送门http://acm.hdu.edu.cn/showproblem.php?pid=3746 题目大意:求最少要在结尾补上几个字符才能形成周期至少为二的字符串。 KMP求周期可看我LA 3026 - Period KMP http://blog.youkuaiyun.com/murmured/article/details/12675953 period=len/(len-next[i]原创 2013-10-18 23:15:28 · 889 阅读 · 0 评论 -
POJ 2406 Power Strings KMP求周期
传送门 http://poj.org/problem?id=2406 题目就是求循环了几次。 记得如果每循环输出为1.。。。 #include #include const int MAXN=1000000+10; char P[MAXN]; int f[MAXN]; int n,m; void getFail() { int i,j; f[0]=f[原创 2013-10-19 09:30:27 · 826 阅读 · 0 评论 -
HDU 3336 Count the string KMP+DP
传送门http://acm.hdu.edu.cn/showproblem.php?pid=3336 KMP的应用。 Orz发明这个算法的人。 状态转移函数 F[i]保证了s[1 .. i] 中 s[i - F[i] + 1 .. i] 与 s[1 .. F[i]]是相等的。 设数组cnt:以 i 结尾的串中所有前缀的计数和 则状态转移方程: cnt[i]= cn原创 2013-10-18 21:07:16 · 807 阅读 · 0 评论 -
POJ 2752 Seek the Name, Seek the Fame (KMP)
传送门 http://poj.org/problem?id=2752 同样是KMP,和 HDU 2594 Simpsons’ Hidden Talents ( http://blog.youkuaiyun.com/murmured/article/details/12867995) 一样,只不过这题是全部输出而已。 故利用失配函数性质,一路next(好吧我的代码是f),最后倒序输出原创 2013-10-19 14:16:50 · 709 阅读 · 0 评论 -
KMP小结
1. KMP模版: 代表题目:POJ 3641 Oulipo KMP http://blog.youkuaiyun.com/murmured/article/details/12871891 int f[MAXN],n,m,ans; void getFail() { f[0]=f[1]=0; int j; for(int i=1;i<n;i++)原创 2013-10-21 22:11:37 · 904 阅读 · 0 评论 -
POJ 3641 Oulipo KMP 水题
http://poj.org/problem?id=3461 直接KMP就好。水题 #include #include const int MAXN=10000+10; const int MAXM=1000000+10; char P[MAXN],T[MAXM]; int f[MAXN],n,m,ans; void getFail() { f[0]=f[1]=0; int j原创 2013-10-19 16:09:20 · 1058 阅读 · 1 评论 -
HDU 2594 Simpsons’ Hidden Talents KMP
传送门http://acm.hdu.edu.cn/showproblem.php?pid=2594 题目要求的是求第一个字符串的前缀是第二个字符串的后缀。 我还以为是第一个字符串在第二个字符串出现,不用后缀。。。。。。 WA了一次。。 看题要仔细。。。。 根据KMP 字符查找过程中,会有一个状态值j,这个j表示s2已经匹配了s1多少个字符。所以当全部匹配完之后,j即原创 2013-10-19 08:49:00 · 954 阅读 · 0 评论
分享