Submission #154761

#TimeUsernameProblemLanguageResultExecution timeMemory
154761junodeveloperCrayfish scrivener (IOI12_scrivener)C++14
100 / 100
628 ms70176 KiB
#include <bits/stdc++.h> using namespace std; int tcnt; int path[1000010],top,cur; int T[1000010][21],dep[1000010]; char ch[1000010]; void Init() {} void TypeLetter(char L) { tcnt++; T[tcnt][0]=cur; dep[tcnt]=dep[cur]+1; int i; for(i=1;i<21;i++) T[tcnt][i]=T[T[tcnt][i-1]][i-1]; ch[tcnt]=L; cur=tcnt; path[++top]=cur; } void UndoCommands(int U) { cur=path[top-U]; path[++top]=cur; } int kth(int u,int k) { int i; for(i=0;k;i++,k>>=1) if(k&1)u=T[u][i]; return u; } char GetLetter(int P) { return ch[kth(cur,dep[cur]-P-1)]; }
#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...