Submission #88004

#TimeUsernameProblemLanguageResultExecution timeMemory
88004PajarajaCrayfish scrivener (IOI12_scrivener)C++17
100 / 100
451 ms148556 KiB
#include <bits/stdc++.h> #define MAXN 1000007 #define MAXL 22 int p[MAXL][MAXN],sz,l[MAXN],brp,d[MAXN]; char t[MAXN]; void Init() {sz++;} void TypeLetter(char L) { l[++brp]=sz; t[sz]=L; d[sz]=d[l[brp-1]]+1; p[0][sz]=l[brp-1]; for(int i=1;i<MAXL;i++) p[i][sz]=p[i-1][p[i-1][sz]]; sz++; } void UndoCommands(int U) {l[brp+1]=l[brp-U]; brp++;} char GetLetter(int P) { int kp=d[l[brp]]-P-1,cur=l[brp]; while(kp!=0) {int x=(kp&-kp); cur=p[__builtin_popcount(x-1)][cur]; kp-=x;} return t[cur]; }
#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...