template:
#include<bits/stdc++.h> using namespace std; int const N=1e5+5; char s[N*2],t[N]; int r[N*2]; int change() { int j=2,len=strlen(t); s[0]='$'; s[1]='#'; for(int i=0; i<len; i++) { s[j++]=t[i]; s[j++]='#'; } s[j++]='#'; return j; } int manacher() { memset(r,0,sizeof(r)); memset(s,0,sizeof(s)); int len=change(),maxn=1,mid=1,ans=-1,sum=0; for(int i=1; i<len; i++) { if(I <MAXN) // I at the left MAXN R & lt [I] = min (MAXN-I, R & lt [MID * 2 - I]); the else R & lt [I] = . 1 ; the while (S [I + R & lt [I ]] == S [IR [I]]) R & lt [I] ++ ; IF (MAXN <I + R & lt [I]) // update the maximum value { MID = I; // Center MID MAXN = I + R & lt [I]; // rightmost of MAXN } ANS = max (ANS, R & lt [I] - . 1 ); // longest substring length palindromic SUM = R & lt + [I] / 2 ; // number of palindromic substring } return SUM; // to Han Han return } int main () { the while (Scanf ( " % S " , T) =! the EOF) { the printf ( " % D \ n- " , manacher ()); } }