#include <stdio.h>
#include <string>
using namespace std;
void get_next(string T,int *next)
{
int i=1,j=0;
next[1]=0;
while(i<T[0])//T[0]为string的长度
{
if(j==0 || T[i]==T[j])
{
i++;
j++;
next[i]=j;
}
else
{
j=next[j];
}
}
}
void get_nextval(string T,int *nextval)
{
int i=1,j=0;
nextval[1]=0;
while(i<T[0])
{
if(j==0 || T[i]==T[j])
{
i++;
j++;
if(T[i]!=T[j])
nextval[i]=j;
else
nextval[i]=nextval[j];
}
else
{
j=nextval[j];//回溯
}
}
}
int main()
{
return 0;
}