Submission #16272

#TimeUsernameProblemLanguageResultExecution timeMemory
16272cometCrayfish scrivener (IOI12_scrivener)C++98
100 / 100
485 ms91896 KiB
struct node{ char t; int x,len; }s[1000000]; int a[1000000][20],sz,cnt; char b[1000000]; void Init() {} void TypeLetter(char L){ int p=0; if(sz)p=s[sz-1].len; s[sz++]={L,cnt++,p+1}; b[cnt-1]=L; if(sz>1){ a[cnt-1][0]=s[sz-2].x; for(int i=1;i<20;i++)a[cnt-1][i]=a[a[cnt-1][i-1]][i-1]; } /* for(int i=0;i<sz;i++)printf("%c,%d,%d ",s[i].t,s[i].x,s[i].len); puts(""); int x=s[sz-1].x; do{ printf("%c ",b[x]); x=a[x][0]; }while(x); puts("");*/ } void UndoCommands(int U) { s[sz]=s[sz-U-1]; sz++; /* for(int i=0;i<sz;i++)printf("%c,%d,%d ",s[i].t,s[i].x,s[i].len); puts(""); int x=s[sz-1].x; do{ printf("%c ",b[x]); x=a[x][0]; }while(x); puts("");*/ } char GetLetter(int P) { int x=s[sz-1].x; P=s[sz-1].len-P; for(int i=19;i>=0;i--){ if(P>(1<<i)){ P-=(1<<i); x=a[x][i]; } } return b[x]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...