
kmp
qq_41555192yl
吾往矣...
展开
-
A - Number Sequence (类型1:匹配子字符串在母串中第几个位置开始出现)
类型1:匹配子字符串在母串中第几个位置开始出现。 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 ...原创 2018-08-18 20:45:05 · 470 阅读 · 0 评论 -
B - Oulipo (类型2:子串在母串中出现了几次(可以有重复的))
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’...原创 2018-08-18 20:51:50 · 211 阅读 · 0 评论 -
C - 剪花布条 (类型3:母串中最多有几个子串,不能重复)
一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长。如果遇见#字符,则不再进行工作。 Output ...原创 2018-08-18 20:57:31 · 271 阅读 · 0 评论 -
F - Power Strings (类型4:求最小循环节有几个)
Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-...原创 2018-08-18 21:11:47 · 246 阅读 · 0 评论 -
E - Period (类型5:当前最小循环节中字符串的个数(不可以补字符串))
For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive), we want to know whether the prefix is a periodic string. That is, for each i (2 ...原创 2018-08-18 21:22:05 · 183 阅读 · 0 评论 -
D - Cyclic Nacklace(类型6:需要再补几个字符能构成一个类似手链那样循环相同的)
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...原创 2018-08-18 21:43:09 · 298 阅读 · 0 评论 -
KMP 各种类型总结
以下是几种KMP类型题: A.类型1:匹配子字符串在母串中第几个位置开始出现。 B.类型2:子串在母串中出现了几次(可以有重复的)。 eg:子串:AZA 母串:AZAZAZA ans = 3; C.类型3:母串中最多有几个子串。 eg:母串:aaaaa 子串:aa ans=2, 最多2个 D.类型4:求最小循环节有几个。 eg: aabaabaabaa...原创 2018-08-18 21:50:35 · 284 阅读 · 1 评论