前缀数组O(n^3)做法
s.substr()的应用非常方便
令string s = ""; string sub1 = s.substr(); //只有一个数字5表示从下标为5开始一直到结尾:sub1 = "56789" string sub2 = s.substr(, ); //从下标为5开始截取长度为3位:sub2 = "567"
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#pragma GCC optimize(2)
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 1000010
#define For(i,a,b) for(int i=a;i<=b;++i)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
int len;
string s;
int ans[N];
void in(int &x){
int y=;char c=g();x=;
while(c<''||c>''){if(c=='-')y=-;c=g();}
while(c<=''&&c>=''){ x=(x<<)+(x<<)+c-'';c=g();}
x*=y;
}
void o(int x){
if(x<){p('-');x=-x;}
if(x>)o(x/);
p(x%+'');
} int main(){
cin>>s;
len=s.size();
For(i,,len-)
For(k,,i)
if(s.substr(,k)==s.substr(i-k+,k))
ans[i]=k;
For(i,,len-)
o(ans[i]),p(' ');
return ;
}