题解东北赛回来再补
#include<stdio.h>
#include<string.h>
int next[500000];
int ans[500000];
char str[500000];
void get_next(int m)
{
int j ,k;
j = 0 ,k = -1;
next[0] = -1;
while(j < m)
{
if(k == -1 || str[k] == str[j])
next[++j] = ++k;
else k = next[k];
}
}
int main ()
{
while(~scanf("%s" ,str))
{
int m = strlen(str);
get_next(m);
int an = 0;
ans[++an] = m;
while(next[ans[an]])
{
int tmp = next[ans[an]];
ans[++an] = tmp;
}
for(int i = an ;i >= 1 ;i --)
if(i == an) printf("%d" ,ans[i]);
else printf(" %d" ,ans[i]);
printf("
");
}
return 0;
}