#x1044. CF432D Prefixes and Suffixes
CF432D Prefixes and Suffixes
Prefixes and Suffixes
题面翻译
给你一个长度为n的长字符串,“完美子串”既是它的前缀也是它的后缀,求“完美子串”的个数且统计这些子串的在长字符串中出现的次数
感谢@转身、已陌路 提供的翻译
题目描述
You have a string , where is the length of string , and its -th character.
Let's introduce several definitions:
- A substring of string is string .
- The prefix of string of length is string .
- The suffix of string of length is string .
Your task is, for any prefix of string which matches a suffix of string , print the number of times it occurs in string as a substring.
输入格式
The single line contains a sequence of characters — string . The string only consists of uppercase English letters.
输出格式
In the first line, print integer — the number of prefixes that match a suffix of string . Next print lines, in each line print two integers . Numbers mean that the prefix of the length matches the suffix of length and occurs in string as a substring times. Print pairs in the order of increasing .
样例 #1
样例输入 #1
ABACABA
样例输出 #1
3
1 4
3 2
7 1
样例 #2
样例输入 #2
AAA
样例输出 #2
3
1 3
2 2
3 1