Problem C: String Problem C

Problem C: String Problem C

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 892  Solved: 289
[Submit][Status][Web Board]

Description

Given a string \(S\)  with length \(n\), you are required to calculate its next array of the KMP algorithm.

Input

One line containing \(S\) \((1\leq |S| \leq 10^6)\)

Output

\(n\) lines, each containing a integer, , indicating the next array value of \(S[i]\)  for \( 0\leq i\leq len(s)-1\)

Sample Input

ababc

Sample Output

0
0
1
2
0

HINT

\(next[0] = 0\)

[Submit][Status]