//source code from Laekov for c0x17#definePrid "FKQH"#include<cstdio>#include<cstring>#include<algorithm>using namespacestd;Const intMAXN =200009; intN, L[maxn], Q[MAXN], VX[MAXN], VY[MAXN];CharA[MAXN];voidManacher () {l[0] =1; for(inti =1, j =0; I < (n <<1) -1; ++i) {intR = ((j +1) >>1) + L[j]-1; intp = i >>1, q = i-p; L[i]= (r >= q)? Min (r-q +1, l[(J <<1)-i]):0; while(P-l[i] >=0&& q + l[i] < n && a[p-l[i]] = = A[q +L[i]]) ++L[i]; if(q + l[i]-1>R) J=i; }} #defineGetLeft (x) (((x) >>1)-l[x]+1)#defineGetRight (x) (((((x) +1) >>1) +l[x]-1)voiddpBOOLd) {Static intQ[MAXN]; intHD =0, TL =0; if(!d) { for(inti =0; I < n; ++i) {if(!tl | | getRight (i <<1) > GetRight (Q[TL-1])) Q[tl+ +] = (i <<1); while(GetRight (Q[HD]) <i)++HD; Vx[i]= (I <<1)-Q[HD] +1; if(I < n-1&& GetRight ((i <<1) +1) > GetRight (Q[TL-1])) Q[tl+ +] = (i <<1) +1; } } Else { for(inti = n-1; I >=0; --i) {if(!tl | | getLeft (i <<1) < GetLeft (Q[TL-1])) Q[tl+ +] = (i <<1); while(GetLeft (Q[HD]) >i)++HD; Vy[i]= Q[hd]-(i <<1) +1; if(I && getLeft (i <<1) -1) < GetLeft (Q[TL-1])) Q[tl+ +] = (i <<1) -1; } }} intMainintargcChar*args[]) { if(ARGC <2|| strcmp (args[1],"-NF") {freopen (Prid". in","R", stdin); Freopen (Prid". out","W", stdout); } scanf ("%s", a); N=strlen (a); Manacher (); DP (0); DP (1); intAns =2; for(inti =1; I < n; ++i) ans= Max (ans, vx[i-1] +Vy[i]); printf ("%d\n", ans);}
String simulation game T2