Test instructions
Give a character x to represent the real a and then output the time to convert
And then it's the longest palindrome string. What length is greater than 1
Ideas:
It's the naked manacher, so we can figure out the conversion relationship.
Code:
#include "cstdlib" #include "Cstdio" #include "CString" #include "Cmath" #include "queue" #include "algorithm" #include " Map "#include" vector "#include" string "#define INF 0x7fffffff#include" iostream "#define LL __int64using namespace std;# Define N 200005char a[n],b[n*2];int rad[n*2];int Main () {char x[2]; while (scanf ("%s%s", X,&a[1])!=-1) {int maxl,maxid,id; int I,len; for (I=1; a[i]; i++) {b[i*2]=a[i]; b[i*2+1]= ' # '; } len=2*i; b[0]= '? '; b[1]= ' # '; b[len]= ' + '; Maxid=id=0; maxl=0; int ANSI; for (I=1; i<len; i++) {if (maxid>i) rad[i]=min (rad[2*id-i],maxid-i); else rad[i]=1; while (B[i-rad[i]]==b[i+rad[i]]) {rad[i]++; } if (Rad[i]+i>maxid) {maxid=rad[i]+i; Id=i; } if (RAD[I]>MAXL) {maxl=rad[i]; Ansi=i; }} if (Maxl-1<2) puts ("No solution!"); else {int kk=x[0]-' a '; int ANS=MAXL-1,ANSL,ANSR; Ansl= (ansi-(ans-1))/2-1; ansr=ansl+ans-1; printf ("%d%d\n", ANSL,ANSR); for (int i=ansl; i<=ansr; i++) {if (a[i+1]-kk< ' a ') printf ("%c", ' Z ' +1-' a ' + (A[I+1]-KK)); else printf ("%c", A[I+1]-KK); } puts (""); }} return 0;}
[Manacher] hdu 3294 girls& #39; The