摘要: KMP的应用如果串s有s(1)循环得到,那么s(1~len-1)一定与s(2~len)匹配,并且len-2+1一定是1的倍数,同理如果由s(1~2),s(1~3)......是一样的道理,但肯定不会这么一个一个枚举,可知可由kmp中的next[]来枚举,减小时间复杂度#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=1000000+10; char s[maxn]; int next[maxn]; void getNext( 阅读全文
posted @ 2013-04-17 21:31 LJ_COME!!!!! 阅读(113) 评论(0) 推荐(0)
摘要: trie的简单应用#include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=10000*10+10; int trie[maxn][11]; int val[maxn],tot; char str[10000+10][15]; int Insert(char *s) { int len=strlen(s); int i,u=0,loc; for(i=0;i<len;i++) { loc=s[i]-'0'; .. 阅读全文
posted @ 2013-04-17 17:19 LJ_COME!!!!! 阅读(113) 评论(0) 推荐(0)