Submission #104262

#TimeUsernameProblemLanguageResultExecution timeMemory
104262arman_ferdousCrayfish scrivener (IOI12_scrivener)C++14
60 / 100
1008 ms91016 KiB
// #include "grader.h" #include <bits/stdc++.h> using namespace std; const int N = 1e6+10; char c[N]; int lev[N]; int cur, freePtr; int p[N][20], state[N], ptr; void Init() { lev[0] = -1; memset(p,-1,sizeof p); c[0] = '?'; cur = 0; freePtr = 1; state[0] = cur; ptr = 0; } void TypeLetter(char L) { int idx = freePtr++; p[idx][0] = cur; c[idx] = L, lev[idx] = lev[cur] + 1; cur = idx; for(int j = 1; j < 20; j++) if(p[cur][j-1] + 1) p[cur][j] = p[p[cur][j-1]][j-1]; state[++ptr] = cur; } void UndoCommands(int U) { state[ptr+1] = state[max(0, ptr - U)]; ptr++; cur = state[ptr]; } char GetLetter(int P) { int tmp = cur, need = lev[cur] - P; for(int j = 19; j >= 0; j--) if(need >= (1<<j)) { need -= (1<<j); tmp = p[tmp][j]; } return c[tmp]; }
#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...