标签:algorithm ack 比较 view nes 情况 start 字典序 sed
A string s is called an (k,l)-repeat if s is obtained by concatenating k>=1 times some seed string t with length l>=1. For example, the string
s = abaabaabaaba
is a (4,3)-repeat with t = aba as its seed string. That is, the seed string t is 3 characters long, and the whole string s is obtained by repeating t 4 times.
Write a program for the following task: Your program is given a long string u consisting of characters ‘a’ and/or ‘b’ as input. Your program must find some (k,l)-repeat that occurs as substring within u with k as large as possible. For example, the input string
u = babbabaabaabaabab
contains the underlined (4,3)-repeat s starting at position 5. Since u contains no other contiguous substring with more than 4 repeats, your program must output the maximum k.
Input
In the first line of the input contains H- the number of test cases (H
Output
For each test cases, you should write exactly one interger k in a line - the repeat count that is maximized.
Example
Input:
1
17
b
a
b
b
a
b
a
a
b
a
a
b
a
a
b
a
b
Output:
4
since a (4, 3)-repeat is found starting at the 5th character of the input string.
题意:
求重复次数最多的连续重复子串出现的次数
思路:
罗穗骞论文和其他博主已经说的比较清楚了,不在赘述。
在此解释一下向左匹配是什么意思。
将i,j同时向左移动,如果s[i]仍然等于s[j],则匹配成功。


#include
#include
#include
#include
#include
#include
View Code
SPOJ - REPEATS Repeats (后缀数组)
标签:algorithm ack 比较 view nes 情况 start 字典序 sed
原文地址:https://www.cnblogs.com/ZGQblogs/p/11176264.html