Submission #31472

#TimeUsernameProblemLanguageResultExecution timeMemory
31472top34051Crayfish scrivener (IOI12_scrivener)C++14
100 / 100
793 ms100784 KiB
#include<bits/stdc++.h> using namespace std; #define maxn 1000005 #define MLOG 20 int n,sz; int ver[maxn], len[maxn]; int par[maxn][23]; char val[maxn]; void Init() { len[0] = -1; } void TypeLetter(char L) { sz++; ver[sz] = sz; len[sz] = len[sz-1] + 1; val[sz] = L; par[sz][0] = ver[sz-1]; for(int i=1;i<=MLOG;i++) par[sz][i] = par[par[sz][i-1]][i-1]; } void UndoCommands(int U) { sz++; ver[sz] = ver[sz-U-1]; len[sz] = len[sz-U-1]; } char GetLetter(int P) { int x; x = ver[sz]; P = len[x]-P; for(int i=0;i<=MLOG;i++) { if(P&1) x = par[x][i]; P/=2; } return val[x]; }
#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...