Codeforces Round 246 (Div. 2)
D
Prefixes and Suffixes
Codeforces
2000
原题
← CE →
翻译中…

You have a string $*s* = *s*_{1}*s*_{2}...*s*_{|*s*|}$, where $|*s*|$ is the length of string $*s*$, and $*s*_{*i*}$ its $*i*$-th character.

翻译中…

Let's introduce several definitions:

翻译中…
  • A substring $*s*[*i*..*j*]$ $(1 ≤ *i* ≤ *j* ≤ |*s*|)$ of string $*s*$ is string $*s*_{*i*}*s*_{*i* + 1}...*s*_{*j*}$.
  • The prefix of string $*s*$ of length $*l*$ $(1 ≤ *l* ≤ |*s*|)$ is string $*s*[1..*l*]$.
  • The suffix of string $*s*$ of length $*l*$ $(1 ≤ *l* ≤ |*s*|)$ is string $*s*[|*s*| - *l* + 1..|*s*|]$.
翻译中…

Your task is, for any prefix of string $*s*$ which matches a suffix of string $*s*$, print the number of times it occurs in string $*s*$ as a substring.

翻译中…

Input

翻译中…

The single line contains a sequence of characters $*s*_{1}*s*_{2}...*s*_{|*s*|}$ $(1 ≤ |*s*| ≤ 10^{5})$ — string $*s*$. The string only consists of uppercase English letters.

翻译中…

Output

翻译中…

In the first line, print integer $*k*$ $(0 ≤ *k* ≤ |*s*|)$ — the number of prefixes that match a suffix of string $*s*$. Next print $*k*$ lines, in each line print two integers $*l*_{*i*}$ $*c*_{*i*}$. Numbers $*l*_{*i*}$ $*c*_{*i*}$ mean that the prefix of the length $*l*_{*i*}$ matches the suffix of length $*l*_{*i*}$ and occurs in string $*s*$ as a substring $*c*_{*i*}$ times. Print pairs $*l*_{*i*}$ $*c*_{*i*}$ in the order of increasing $*l*_{*i*}$.

翻译中…

样例

Input #1
ABACABA
Output #1
3
1 4
3 2
7 1
InputCopy OutputCopy
Input #2
AAA
Output #2
3
1 3
2 2
3 1
InputCopy OutputCopy
题目信息
题号
432D
时间限制
1 s
内存限制
256 MB
标签
动态规划
后缀结构
字符串
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。