/*POJ 2752*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char str[400002];
int next[400002];
int pre[40];
int len;
while(scanf("%s",str) != EOF)
{
int i, j, count;
len = strlen(str);
i = 0;
j = -1;
next[i] = -1;
for( ; i<len; )
{
if(j == -1 || str[i] == str[j])
{
++i;
++j;
next[i] = j;
}
else
j = next[j];
}
count = 0;
j = len;
while(j != 0)
{
pre[++count] = j;
j = next[j];
}
while(count > 1)
{
printf("%d ",pre[count]);
count --;
}
printf("%d/n",pre[count]);
}
system("pause");
return 0;
}
POJ 2752
最新推荐文章于 2020-08-24 20:09:30 发布