
KMP
文章平均质量分 84
无
呵呵world
这个作者很懒,什么都没留下…
展开
-
Count the string(KMP-next数组的应用)
Count the stringHDU - 3336 It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this string. For example: s: "abab" The prefixes are: "a", "ab.原创 2021-07-31 08:53:47 · 127 阅读 · 1 评论 -
Theme Section-主题部分 (KMP)
Theme Section 目录 Theme Section 题意描述:给n组字符串,求字符串除前缀和后缀有相同字符之外,字符串中间有没有与它们相同的字符串,如果有输出相同字符串长度,没有输出0 解题思路:利用next数组字符串求前后缀相同个数,再记录中间与和前缀有相同的字符串长度的位置,因为我们存的值是从大到小排的,所以会先判断中间字符串部分有没有与长一点的字符串的next相等的,如果没有接着判断小的,返回的值就是所求长度。 易错分析:没有利用kmp数组来判断中间字符串,根据自己写的数据来写..原创 2021-07-31 08:52:24 · 269 阅读 · 0 评论 -
Number Sequence-数字序列(KMP字符串匹配)
Number Sequence HDU - 1711 Given two sequences of numbers : a[1], a[2], ...... , a[N], and b[1], b[2], ...... , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2], ...... , a[K..原创 2021-08-01 08:48:21 · 503 阅读 · 0 评论 -
Oulipo-欧力波(KMP字符串匹配问题)
Oulipo-欧力波 HDU - 1686 The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group. A quote from the book: Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair..原创 2021-07-31 08:50:09 · 237 阅读 · 0 评论 -
剪花布条 HDU - 2087(KPM字符串匹配问题)
剪花布条 HDU - 2087 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。 Output 输出能从花纹布中剪出的最多小饰条个数,如果一块都没有,那就老老实实输出0,每.原创 2021-07-31 08:51:45 · 147 阅读 · 0 评论 -
Period -期间 (KMP-next数组的应用)
Period-期间 目录 Period-期间 POJ - 1961 题意描述:对于给定的字符串,求该字符串的是循环字符串的前缀长度。输出前缀大小和前缀的周期。 解题思路:本题要求字符串有循环子串且循环次数大于1的前缀长和该前缀字符串中子串循环次数。利用next数组求前缀与后缀相同字符长度,然后因为我们要求的是从头开始的前缀里含的循环子串。只需要定义一个for循环,从头开始遍历字符串,即根据字符串是否循环的公式来判读长度为(1~字符串长度)的字符串是否是循环字符串,如果是输出长度和循环个...原创 2021-07-31 08:54:13 · 113 阅读 · 0 评论 -
Seek the Name, Seek the Fame(KMP-next数组&详解)
The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names to their newly-born babies. They seek the name, and at the same time seek the fame. In order to escape from such boring job, the inn原创 2021-07-19 10:56:43 · 311 阅读 · 0 评论 -
Simpsons’ Hidden Talents辛普森一家的隐藏天赋(next数组和kmp字符串匹配)
辛普森一家的隐藏天赋 HDU - 2594 Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge: Yeah, what is it? Homer: Take me for example. I want to find out if I have a talent in politics, OK? Marge: OK. Homer: So I take .原创 2021-07-21 16:54:26 · 274 阅读 · 0 评论 -
Cyclic Nacklace(KMP-next数组应用+循环字符串判断)
CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and thinking about how to tide over the last days. Being inspired by the entrepre原创 2021-07-21 16:44:28 · 129 阅读 · 0 评论 -
Power Strings电源线(KMP求最小重复子串的循环个数)
Each test case is a line of input representing s, a string of printable characters. The length of s will be at least 1 and will not exceed 1 million characters. A line containing a period follows the last test case. Output For each s you should print the原创 2021-07-19 16:36:53 · 196 阅读 · 0 评论