POJ - 3693 Maximum repetition substring (后缀数组)
标签:str main rem san init 出现 define top clear
The repetition number of a string is defined as the maximum number R such that the string can be partitioned into R same consecutive substrings. For example, the repetition number of "ababab" is 3 and "ababa" is 1.
Given a string containing lowercase letters, you are to find a substring of it with maximum repetition number.
Input
The input consists of multiple test cases. Each test case contains exactly one line, which
gives a non-empty string consisting of lowercase letters. The length of the string will not be greater than 100,000.
The last test case is followed by a line containing a ‘#‘.
Output
For each test case, print a line containing the test case number( beginning with 1) followed by the substring of maximum repetition number. If there are multiple substrings of maximum repetition number, print the lexicographically smallest one.
Sample Input
ccabababc
daabbccaa
#
Sample Output
Case 1: ababab
Case 2: aa
题意:
求重复次数最多的连续重复子串所在的子串
思路:
https://www.cnblogs.com/ZGQblogs/p/11176264.html
通过这篇博客找出重复次数最多的连续重复子串出现的次数.
然后在后缀数组的前缀里寻找符合条件的子串.因为后缀数组已经按字典序排好序,所以找到后立即退出.
具体详见代码注释:


#include
#include
#include
#include
#include
#include
View Code
Maximum repetition substring
POJ - 3693
POJ - 3693 Maximum repetition substring (后缀数组)
标签:str main rem san init 出现 define top clear
原文地址:https://www.cnblogs.com/ZGQblogs/p/11177025.html
评论