Submission #31046

#TimeUsernameProblemLanguageResultExecution timeMemory
3104614kgCrayfish scrivener (IOI12_scrivener)C++11
100 / 100
943 ms94868 KiB
struct TYPE{ char num; int next_0, lev, next[21]; } d[1000001]; int n, p[21]; void Init(){ p[0] = 1; for (int i = 1; i <= 20; i++) p[i] = p[i - 1] * 2; } void TypeLetter(char x){ n++, d[n].next_0 = n, d[n].num = x, d[n].lev = d[n - 1].lev + 1; d[n].next[0] = d[n - 1].next_0; for (int i = 1; i <= 20; i++) d[n].next[i] = d[d[n].next[i - 1]].next[i - 1]; } void UndoCommands(int x) { n++, d[n].next_0 = d[n - x - 1].next_0, d[n].lev = d[d[n].next_0].lev; } char GetLetter(int _in){ int x = n, y = d[n].lev-_in-1; while(1){ if(x!=d[x].next_0) x=d[x].next_0; else if(y==0) return d[x].num; for(int i=20; i>=0; i--) if(p[i]<=y){ x=d[x].next[i], y-=p[i]; break; } } }
#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...