manacher板子
1 int main(){ 2 scanf("%s",rn+1); 3 n=strlen(rn+1); 4 int j=0; 5 for(int i=1;i<=n;++i) 6 S[++j]='#',S[++j]=rn[i]; 7 S[++j]='#'; 8 S[0]='#',S[j+1]='#'; 9 for(int i=0;i<=j;++i)p[i]=sm1[i]=sm2[i]=0; 10 int id=0,mx=0; 11 for(int i=1;i<=j;++i){ 12 p[i]=i<mx?min(p[2*id-i],mx-i):1; 13 while(i-p[i]>=1&&i+p[i]<=j&&S[i-p[i]]==S[i+p[i]])p[i]++; 14 if(mx<i+p[i])mx=i+p[i],id=i; 15 } 16 }