Topic links
Depending on the left and right of the palindrome string, the left side of each point is turned over, in order to avoid repeating the update, the right endpoint RR that is currently updated is recorded.
1#include <algorithm>2#include <iostream>3#include <cstdlib>4#include <cstring>5#include <cstdio>6#include <string>7#include <cmath>8#include <ctime>9#include <queue>Ten#include <stack> One#include <map> A#include <Set> - #defineRre (i,r,l) for (int i= (r); i>= (l); i--) - #defineRe (I,L,R) for (int i= (l); i<= (R); i++) the #defineClear (A, B) memset (A,b,sizeof (a)) - #defineInOut (x) printf ("%d", (x)) - #defineDouin (x) scanf ("%lf", &x) - #defineStrin (x) scanf ("%s", (x)) + #defineLLin (x) scanf ("%lld", &x) - #defineOP operator + #defineCSC Main Atypedef unsignedLong LongULL; attypedefConst intCInt; -typedefLong LongLL; - using namespacestd; - voidInin (int&ret) - { -ret=0;intf=0;CharCh=GetChar (); in while(ch<'0'|| Ch>'9'){if(ch=='-') f=1; ch=GetChar ();} - while(ch>='0'&&ch<='9') ret*=Ten, ret+=ch-'0', ch=GetChar (); toret=f?-Ret:ret; + } - Chars[100010]; the BOOLbo[100010][ -]; * intn,a[100010],b[100010]; $ voidFindintx)Panax Notoginseng { -Re (I,0, -)if(!Bo[x][i]) the { +S[x]= (Char)('a'+i); A return ; the } + } - intMain () $ { $ inin (n); -Re (I,1, N) inin (a[i]); -Re (I,1, N-1) Inin (B[i]); thes[1]='a';intRr=1; -Re (I,1, N)Wuyi { the if(s[i]==0) Find (i), rr=i; - intLen=a[i]>>1; Wu intl=i-len-1, r=i+len+1; - if(l>0&&r<=n) bo[r][s[l]-'a']=1; About while(rr<r-1) rr++,s[rr]=s[2*i-RR]; $Len=b[i]>>1; -l=i-len,r=i+len+1; - if(l>0&&r<=n) bo[r][s[l]-'a']=1; - while(rr<r-1) rr++,s[rr]=s[2*i-rr+1]; A } +Re (I,1, N) printf ("%c", S[i]); the return 0; -}
bzoj3325 [Scoi2013] Password