2014年7月29日
摘要: 题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1213典型的并查集,属于水题吧,但学会了路径压缩。 1 /*非递归,非路径压缩*/ 2 #include 3 const int maxn=1000+5; 4 int fa[maxn]; 5 void i... 阅读全文
posted @ 2014-07-29 17:43 BMESwimming 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1686又是一道字符串匹配问题,同样也是KMP算法,就是多记一下模式串的重复频率。 1 #include 2 #include 3 const int maxn=10000+5,maxm=1000000+1... 阅读全文
posted @ 2014-07-29 15:33 BMESwimming 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 题目来源:http://poj.org/problem?id=2406题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1358 两道基本一样的题目,主要考察KMP算法中next数组的性质,根据next[len]可以知道前len-1字符串最长前缀和后缀... 阅读全文
posted @ 2014-07-29 15:28 BMESwimming 阅读(131) 评论(0) 推荐(0) 编辑