![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
KMP & 扩展KMP
破晓aa
这个作者很懒,什么都没留下…
展开
-
kmp next数组的简单运用
kmp不仅仅是常规的那些作用,其next数组也有很大作用,最常用的就是求字符串循环节(惊叹还有这种操作!!!)。next[i]代表的是前 i - 1个字符中的最长相同前缀后缀, i - next[i]就代表了最小循环节。...原创 2018-08-13 10:03:49 · 539 阅读 · 0 评论 -
kmp
int nex[10000000];void Getnext(char *st){ int j, k; j = 0; k = -1; int l = strlen(st); nex[0] = -1; while(j < l - 1) { if(k == -1 || st[j] == st[k]) { k++; j++...原创 2018-05-19 16:10:10 · 101 阅读 · 0 评论 -
扩展kmp模板
const int maxn = 5 * 1e4 + 100;char s1[maxn], s2[maxn];int ne[maxn], ex[maxn];void Getnext(char *st) //得到next数组,是把st既当成母串又当成子串{ int len = strlen(st); ne[0] = len; int i = 0; while...原创 2018-12-27 20:49:18 · 179 阅读 · 0 评论 -
最小表示法
与最小表示法相关的问题差不多是这样的: 对于一个字符串S,求S的循环的同构字符串S’中字典序最小的一个 。(也就是说S是一个环形的字符串,可以以任意一个字符作为开始。) int getmin(char *st){ int len = strlen(st); int i, j, k; i = 0; j = 1; k = 0; while(i &...原创 2018-12-28 20:56:55 · 146 阅读 · 0 评论 -
hdu4300 Clairewd’s message (扩展KMP)
Clairewd is a member of FBI. After several years concealing in BUPT, she intercepted some important messages and she was preparing for sending it to ykwd. They had agreed that each letter of these mes...原创 2019-01-03 19:59:54 · 189 阅读 · 0 评论