TopCoder

User's AC Ratio

100.0% (1/1)

Submission's AC Ratio

100.0% (1/1)

Tags

Description

For a string $X = X _ 0 X _ 1 X _ 2 \cdots $ , we denote its substring $X _ a X _ {a+1} \cdots X _ {b-1}$ as $X[a,b)$ .

Given a string $S = S _ 0 S _ 1 S _ 2 \cdots S _ {N-1}$ of length $N$ . Find an array of integers $0 = a _ 0 \lt a _ 1 \lt a _ 2 \lt \ldots \lt a _ k = N$ so that $S[a _ 0 , a _ 1) , S[a _ 1 , a _ 2) , \ldots , S[a _ {k-1} , a _ k)$ is the Lyndon Factorization of $S$ .

Input Format

$S$

Output Format

$a _ 0$ $a _ 1$ $a _ 2$ $\cdots$ $a _ k$

Sample Input 1

babaabaab

Sample Output 1

0 1 3 6 9

Sample Input 2

ababacaca

Sample Output 2

0 8 9

Hints

  • $1 \leq N \leq 5 \times 10^ {5}$
  • Each character of $S$ is a lowercase English letter.

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152
12 5000 2097152 2097152
13 5000 2097152 2097152
14 5000 2097152 2097152
15 5000 2097152 2097152
16 5000 2097152 2097152
17 5000 2097152 2097152
18 5000 2097152 2097152
19 5000 2097152 2097152
20 5000 2097152 2097152
21 5000 2097152 2097152
22 5000 2097152 2097152