2012年11月17日

摘要: 转载自:http://news.cnblogs.com/n/164019/ 阅读全文
posted @ 2012-11-17 20:18 Raining Days 阅读(134) 评论(0) 推荐(0) 编辑

2012年11月12日

摘要: 汉语提,题意清楚。当初还卡了我一个上午。哎。ac代码:View Code #include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <string>#include <set>using namespace std;const int maxn=26;struct node{ int cnt; node *next[maxn]; node() { cnt=0; for( 阅读全文
posted @ 2012-11-12 16:44 Raining Days 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 字典树的题是我一个月前做的了,到现在依然记得,他是我ac的第一个字典树题目。嘻嘻。ac代码:View Code #include <algorithm>#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <string>#include <set>using namespace std;const int maxn=26;const int maxlen=100;char ss1[50005][maxl 阅读全文
posted @ 2012-11-12 16:41 Raining Days 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 这题的题解随处可见。仅供参考。ac代码:View Code #include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <string>#include <set>using namespace std;const int maxn=10;const int maxlen=11;typedef struct TrieNode{ int flg; struct TrieNo 阅读全文
posted @ 2012-11-12 16:39 Raining Days 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 类似hash的题吧,翻译文稿。字典树搞的。ac代码:View Code #include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <string>#include <set>using namespace std;const int maxn=26;const int maxlen=3001;string tt,sss;struct node{ bool flg; st 阅读全文
posted @ 2012-11-12 16:37 Raining Days 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 这个题是一个好题,题意比较简单,我就不赘述了。能让你对kmp的认识更近一步吧。我以前对kmp的理解仅限于动态规划或者前后缀之类的层次上。自己浅薄。ac代码:View Code #include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;const int maxn=1000000+5;char s[maxn];int n,next[maxn],ncas;void init( 阅读全文
posted @ 2012-11-12 16:29 Raining Days 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 这题大概是数据比较水吧,我本以为会wa或者什么的,没想到直接亮了。讨论版里面神代码多的是,但是我也想把我的代码贴出来:ac代码:View Code #include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;const int maxn=100000+5;char s1[maxn],s2[maxn];int len1,len2,next[maxn];void get_nex 阅读全文
posted @ 2012-11-12 16:17 Raining Days 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 此题就是传说中的nlogn都不可过的那题吧。网上有O(n)的解法,具体的我就不说了。代码也不贴了。我也是从人家那里学过来的。 阅读全文
posted @ 2012-11-12 16:12 Raining Days 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 这个更是比较简单,就是找一个串在另一个串是否有出现,如果没有出现,输出-1,如果出现了,输出index,如果出现多次,输出最小的那个index。下面是我的代码:ac代码:View Code #include <algorithm>#include <iostream>#include <stdlib.h>#include <string.h>#include <limits.h>#include <stdio.h>#include <math.h>#include <vector>#include 阅读全文
posted @ 2012-11-12 16:07 Raining Days 阅读(131) 评论(0) 推荐(0) 编辑
摘要: kmp,题意是找一个字符串既是s1串的前缀同时又是s2后缀,并且要这个字符串的长度最大。思路是把s2串当成是文本串,s1串当成是模式串,两个串KMP。具体的见代码。呵呵。ac代码:View Code #include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;const int maxn=50000+5;char s1[maxn],s2[maxn];int n,len1,l 阅读全文
posted @ 2012-11-12 16:01 Raining Days 阅读(186) 评论(0) 推荐(0) 编辑

导航