Submission #63342

#TimeUsernameProblemLanguageResultExecution timeMemory
63342VahanCrayfish scrivener (IOI12_scrivener)C++17
100 / 100
925 ms118308 KiB
#include<cmath> char last; void Init() {} int t=-1,er[2000000],a[1000005][23],x[25]; char v[2000000]; void TypeLetter(char L) { if(x[0]==0) { x[0]=1; for(int i=1;i<=20;i++) x[i]=x[i-1]*2; } t++; if(t==0) er[t]=1; else er[t]=er[t-1]+1; v[t]=L; for(int i=0;x[i]<er[t];i++) { if(i==0) a[t][0]=t-1; else a[t][i]=a[a[t][i-1]][i-1]; } } void UndoCommands(int U) { t++; er[t]=er[t-U-1]; v[t]=v[t-U-1]; for(int i=0;x[i]<er[t];i++) a[t][i]=a[t-U-1][i]; } char GetLetter(int P) { int p=er[t]-P-1; int e=t,b[25]; int r=-1; while(p!=0) { r++; if(p%2==0) b[r]=0; else b[r]=1; p/=2; } for(int i=r;i>=0;i--) if(b[i]==1) e=a[e][i]; return v[e]; }
#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...