![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
KMP
Lesroad
这个作者很懒,什么都没留下…
展开
-
hdu3336—Count the string(kmp+dp)
Count the stringTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11169 Accepted Submission(s): 5207Problem Description It is well known that Ae原创 2017-08-26 22:02:10 · 250 阅读 · 0 评论 -
poj3461——Oulipo(kmp)
传送门:点我 题目大意:给你两个字符串p和s,求出p在s中出现的次数。 贴代码: #include #include #include #include using namespace std; #define N 10006 #define NN 1000003 char s[NN],s1[N]; int Next[N]; void make_Next(int n) { i原创 2017-08-26 22:08:59 · 156 阅读 · 0 评论 -
poj2752—Seek the Name, Seek the Fame
传送门:点我 Input The input contains a number of test cases. Each test case occupies a single line that contains the string S described above. Restrictions: Only lowercase letters may appear in t原创 2017-08-26 22:12:48 · 167 阅读 · 0 评论 -
poj1961—Period(kmp周期性质)
传送门:点我 Sample Input 3 aaa 12 aabaabaabaab 0 Sample Output Test case #1 2 2 3 3 Test case #2 2 2 6 2 9 3 12 4 题意:给一个字符串判断前缀是否构成周期串,输出周期串长度和周期数 知识点:如果一个字符串有最小周期,那么循环节为n-next[n],周期数为n / (n-next[原创 2017-08-26 22:24:57 · 257 阅读 · 0 评论 -
hdu1867—A + B for you again
传送门:点我 Sample Input asdf sdfg asdf ghjk Sample Output asdfg asdfghjk 题意:计算两字符串相加要求1.长度优先最小 2.字典序小的顺序输出 注意:题目要求的是最短的字符串能包含所给的两个字符串,这里的包含一定是前一部分或后一部分包含,不能中间包含 #include #include #原创 2017-08-26 22:42:21 · 207 阅读 · 0 评论 -
hdu3746—Cyclic Nacklace(kmp周期性质)
传送门:点我 Sample Input 3 aaa abca abcde Sample Output 0 2 5 题意:给你一个字符串,要求将字符串的全部字符最少循环2次需要添加的字符数。 #include #include #include using namespace std; #define N 100005 int Next[N]; char s[N]; vo原创 2017-08-26 22:48:27 · 150 阅读 · 0 评论 -
【Wannafly挑战赛9-B】数一数
【Wannafly挑战赛9-B】数一数 链接:https://www.nowcoder.net/acm/contest/71/B 题目就不贴了。。 设res[i]为第i行的最终结果,可以想到,res[i]为0或不为0。长度不是最短的字符串res一定0,因为res是所有子串数量的乘积,对于每个字符串,只有长度最短的字符串乘过之后才会有结果,其余的res都是0。有多个长度最短的,结果都一样,...原创 2018-02-08 19:11:00 · 73 阅读 · 0 评论 -
【2018年全国多校算法寒假训练营练习比赛(第五场)-C】字符串问题(KMP)
【2018年全国多校算法寒假训练营练习比赛(第五场)-C】字符串问题(KMP) 题目链接:https://www.nowcoder.com/acm/contest/77/C 【题意】 求一个字符串中最长的子串,要求子串既是原串的前缀又是后缀,除前后缀还在中间出现过。 【思路】 KMP的应用,首先要理解next数组的含义:一个字符串中 前缀 和 后缀的最长公共长度,next的值也是在...原创 2018-02-27 19:16:00 · 87 阅读 · 0 评论