随笔分类 -  KMP

hdu6153 扩展kmp求一个字符串的后缀在另一个字符串出现的次数。
摘要:/** 题目:hdu6153 链接:http://acm.hdu.edu.cn/showproblem.php?pid=6153 题意:给定两个串,求其中一个串t的每个后缀在另一个串s中出现的次数乘以其长度之和。 思路:扩展kmp 先将两个字符串翻转过来。那么变成求t串每个前缀在s串出现的次数。 直接扩展kmp求出extend[i]表示s串[i,n-1]子串和t串的最长公共前缀。 那么s串从i开... 阅读全文

posted @ 2017-08-21 11:39 hnust_accqx 阅读(216) 评论(0) 推荐(0)

hdu3613 Best Reward 扩展kmp or O(n)求最大回文子串
摘要:/** 题目:hdu3613 Best Reward 链接:http://acm.hdu.edu.cn/showproblem.php?pid=3613 题意:有一个字符串,把他切成两部分。 如果这部分是回文串,那么他的值为所有字母的权值和。否则这部分值为0;这两部分的值和为该切法的权值。 求最大的切法的权值。 思路: 如果能够判断[0,i],[i,n-1]是一个回文串(0 #include ... 阅读全文

posted @ 2017-08-13 13:49 hnust_accqx 阅读(349) 评论(0) 推荐(0)

hdu4333 Revolving Digits 扩展kmp
摘要:/** 参考:http://blog.csdn.net/acdreamers/article/details/8313828 参考:http://www.61mon.com/index.php/archives/186/ 题目:hdu4333 Revolving Digits 链接:http://acm.hdu.edu.cn/showproblem.php?pid=4333 题意: 给定一个数... 阅读全文

posted @ 2017-08-13 10:56 hnust_accqx 阅读(143) 评论(0) 推荐(0)

codeforces 825F F. String Compression dp+kmp找字符串的最小循环节
摘要:/** 题目:F. String Compression 链接:http://codeforces.com/problemset/problem/825/F 题意:压缩字符串后求最小长度。 思路: dp[i]表示前i个字符需要的最小次数。 dp[i] = min(dp[j]+w(j+1,i)); (0 #include #include #include #include #includ... 阅读全文

posted @ 2017-08-11 22:00 hnust_accqx 阅读(152) 评论(0) 推荐(0)

poj1961 Period kmp解决找字符串的最小循环节
摘要:/** 题目:poj1961 Period 链接:http://poj.org/problem?id=1961 题意:求从1到i这个前缀(2 #include #include #include #include #include #include using namespace std; #define ms(x,y) memset(x,y,sizeof x) const int ... 阅读全文

posted @ 2017-08-11 21:11 hnust_accqx 阅读(124) 评论(0) 推荐(0)

导航