3026 - Period
Time limit: 3.000 seconds
For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefi...
分类:
编程语言 时间:
2015-03-05 22:23:08
阅读次数:
173
转载请注明来源,并包含相关链接。网上有很多讲解KMP算法的博客,我就不浪费时间再写一份了。直接推荐一个当初我入门时看的博客吧: http://www.cnblogs.com/yjiyjige/p/3263858.html 这位同学用详细的图文模式讲解了KMP算法,非常适合入门。 ----------...
分类:
编程语言 时间:
2015-03-05 22:16:21
阅读次数:
190
转载请注明来源,并包含相关链接。网上有很多讲解KMP算法的博客,我就不浪费时间再写一份了。直接推荐一个当初我入门时看的博客吧:http://www.cnblogs.com/yjiyjige/p/3263858.html这位同学用详细的图文模式讲解了KMP算法,非常适合入门。-------------...
分类:
编程语言 时间:
2015-03-05 12:45:14
阅读次数:
104
题目来源:URAL 1684. Jack's Last Word题意:输入a b 把b分成若干段 每一段都是a的前缀思路:b为主串然后用a匹配b 记录到b的i位置最大匹配的长度 然后切割 切割的时候要从后往前假设a = abac b = abab 那么假设从前往后 首先覆盖了aba 然后b就不能覆盖...
分类:
其他好文 时间:
2015-03-02 14:46:35
阅读次数:
135
一 简介KMP算法是一种改进的字符串匹配算法,由D.E.Knuth与V.R.Pratt和J.H.Morris同时发现,因此人们称它为克努特—莫里斯—普拉特操作(简称KMP算法)。KMP算法的关键是利用匹配失败后的信息,尽量减少模式串与主串的匹配次数以达到快速匹配的目的。二 基于部分匹配表的KMP算法举例来说,有一个字符串”BBC ABCDAB ABCDABCDABDE”,我想知道,里面是否包含搜索串...
分类:
编程语言 时间:
2015-03-01 19:48:12
阅读次数:
153
与上题不同的是: 在ans++; 后,要同时把j=0; 因为这道找出来的子序列不允许重叠,2个子序列要是重叠只能取其一嘛。 1 #include 2 #include 3 const int max=1000+10; 4 char p[max]; 5 char t[max]; 6 int f[m.....
分类:
其他好文 时间:
2015-03-01 18:20:54
阅读次数:
149
水题 1 #include 2 #include 3 const int maxn=1e6+5; 4 const int maxm=1e4+5; 5 int p[maxm]; 6 int t[maxn]; 7 int f[maxm]; 8 int n,m; 9 void getfail()10 {1...
分类:
其他好文 时间:
2015-03-01 17:01:46
阅读次数:
166
今天就这题照着别人的代码学了字典树...
这篇论文:http://wenku.baidu.com/view/d2ba836fb84ae45c3b358ca8.html介绍了各种字典树的运用,长了好多姿势,很有启发性
归纳一下字典树的应用:
检索(主要功能)
串排序
在DP中减少无效的状态转移
最长公共前缀问题(LCP)转化成LCA
tire+KMP 构成AC自动机数据结构
...
分类:
其他好文 时间:
2015-02-28 08:57:53
阅读次数:
165
1 // KMP 2 3 void get_next(char s[],int next[]) 4 { 5 int i,j; 6 i=1;j=0; 7 next[1]=0; 8 int len=strlen(s); 9 while(ilen2)42 ...
分类:
其他好文 时间:
2015-02-27 06:39:52
阅读次数:
230
Problem DescriptionGenerally speaking, there are a lot of problems about strings processing. Now you encounter another such problem. If you get two strings, such as “asdf” and “sdfg”, the result of the...
分类:
其他好文 时间:
2015-02-23 16:46:39
阅读次数:
148