Submission #202085

#TimeUsernameProblemLanguageResultExecution timeMemory
202085DavidDamianCrayfish scrivener (IOI12_scrivener)C++11
100 / 100
536 ms65784 KiB
#include<bits/stdc++.h> using namespace std; int node[1000006]; int NEXT_FREE_INDEX=1; int n=1; int lv[1000006]; char letter[1000006]; int ancestor[21][1000006]; int len; int cont=0; void Init() { len=-1; lv[0]=-1; } void TypeLetter(char L) { int u=NEXT_FREE_INDEX++; //Last created node node[n]=u; lv[u]=lv[ node[n-1] ]+1; letter[u]=L; ancestor[0][u]=node[n-1]; for(int i=1;i<=20;i++){ ancestor[i][u]=ancestor[i-1][ ancestor[i-1][u] ]; } n++; } void UndoCommands(int U) { node[n]=node[n-U-1]; n++; } char GetLetter(int P) { int u=node[n-1]; int d=lv[u]-P; for(int i=20;i>=0;i--){ if(d & (1<<i)){ u=ancestor[i][u]; } } return letter[u]; }
#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...