![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
字符串--kmp
exmy
Less is more, and more is less.
展开
-
poj--2752 Seek the Name, Seek the Fame(KMP)
poj 2752题解求串中前缀和后缀相同的子串长度。KMP算法中的 next 数组,next[i] 记录的是以 i 为结束位置的串的 前缀和后缀相同 的最大匹配长度。那么,利用此数组,指针 j 不断回滚,j = next[ next[ … next[j]…]],当 S[j] == S[S.lenght() - 1] 的时候,会有一个长度为 j + 1的串满足条件。#include <iostream原创 2016-04-14 19:23:43 · 370 阅读 · 0 评论 -
hdoj--2087 剪花布条
hdoj 2087题解不可重叠的匹配。#include <iostream>#include <algorithm>#include <string>using namespace std;int Next[200];void preKMP(string& s){ int i, j; j = Next[0] = -1; i = 0; while(i < (in原创 2016-04-14 18:36:39 · 502 阅读 · 0 评论 -
poj--3461 Oulipo(KMP)
poj 3461题意求串W在串T中出现的次数,可重叠。题解kMP模板。#include <iostream>#include <string>#include <fstream>#include <algorithm>using namespace std;int t;int Next[10001];void kmp_pre(string x){ int i, j; j原创 2016-04-13 11:42:26 · 325 阅读 · 0 评论