码迷,mamicode.com
首页 >  
搜索关键字:kmp    ( 3157个结果
poj2185 Milking Grid (最小覆盖矩阵)
//给定一个由字符组成的矩阵,求出它的面积最小的覆盖矩阵 //可以求出每一行的最小覆盖子串的长度,只要对这些长度求最小公倍数,就可以获得最小覆盖矩阵的宽度。 //同理,求出每一列的最小覆盖子串的长度,再求最小公倍数,就可以获得最小覆盖矩阵的高度了。 # include # include # include using namespace std; char a[10010][100]; i...
分类:其他好文   时间:2014-08-15 00:01:06    阅读次数:187
POJ 2752 Seek the Name, Seek the Fame
题目大意:给你一个字符串,让你找出这个字符串中有多少满足下列条件的字串:该字串既是母串的前缀,也是字串的后缀。         解题思路:此题着重考察对KMP 算法中的Next 数组的理解。 代码如下: #include #include #include #include #include #include using namespace std ; const int MAXN = 40...
分类:其他好文   时间:2014-08-14 23:54:56    阅读次数:250
poj 3461 Oulipo(KMP模板题)
poj 3461 Oulipo(KMP模板题)...
分类:其他好文   时间:2014-08-14 20:38:29    阅读次数:273
POJ 3461 Oulipo(KMP字符串匹配)
题意  给你两个字符串p和s  求p在s中出现的次数  很裸的kmp 因为不止匹配一次  每次找到后还要循环j=next[j]的过程   知道到达s的终点 #include #include using namespace std; const int N = 10005, M = 1000005; int next[N], ans, n; char p[N], s[M]; void kmp...
分类:其他好文   时间:2014-08-14 20:36:39    阅读次数:248
HDU 2222 Keywords Search
题意:要你求出给定的单词表在一个字符串中出现了几个单词 思路:没学AC自动机之前,用KMP做了一下,果断超时。后来问了一下朋友,才知道要用AC自动机。涨姿势了 http://blog.csdn.net/u012313382/article/details/38541509 本题就是一道AC自动机的模板题 AC代码: #include #include #include #includ...
分类:其他好文   时间:2014-08-14 16:45:38    阅读次数:202
KMP - 简单应用
#include#includechar s1[1000005],s2[1000005];int next[1000005];void get_next(char s[1000005]){ int i = 0; int len = strlen(s); next[0] = -1;...
分类:其他好文   时间:2014-08-14 16:37:38    阅读次数:174
算法学习笔记 KMP算法之 next 数组详解
最近回顾了下字符串匹配 KMP 算法,相对于朴素匹配算法,KMP算法核心改进就在于:待匹配串指针 i 不发生回溯,模式串指针 j 跳转到 next[j],即变为了 j = next[j]. 由此时间复杂度由朴素匹配的 O(m*n) 降到了 O(m+n), 其中模式串长度 m, 待匹配文本串长 n.其中,比较难理解的地方就是 next 数组的求法。...
分类:其他好文   时间:2014-08-14 01:35:27    阅读次数:336
hdu 3746 Cyclic Nacklace (KMP求最小循环节)
//len-next[len]为最小循环节的长度 # include # include # include using namespace std; int len; char a[100010]; int next[100010]; void Getnext() { int i=0,j=-1; next[0]=-1; while(i<=len) { ...
分类:其他好文   时间:2014-08-13 22:41:57    阅读次数:450
poj 2406 Power Strings (KMP)
# include # include # include using namespace std; int len; char a[1000010]; int next[1000010]; void Getnext() { int i=0,j=-1; next[0]=-1; while(i<=len) { if(j==-1||a[j]==a[...
分类:其他好文   时间:2014-08-13 22:34:17    阅读次数:262
poj2752 Seek the Name, Seek the Fame(next数组的运用)
poj2752 Seek the Name, Seek the Fame(next数组的运用)...
分类:其他好文   时间:2014-08-13 22:33:37    阅读次数:320
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!