Submission #103002

#TimeUsernameProblemLanguageResultExecution timeMemory
103002wxh010910Crayfish scrivener (IOI12_scrivener)C++17
100 / 100
834 ms90668 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1234567; const int LOG = 20; int t, from[N], depth[N], anc[N][LOG]; char type[N]; void Init() { t = 1; } void TypeLetter(char L) { type[t] = L; depth[t] = depth[from[t - 1]] + 1; anc[t][0] = from[t - 1]; for (int i = 1; depth[t] >> i; ++i) { anc[t][i] = anc[anc[t][i - 1]][i - 1]; } from[t] = t; ++t; } void UndoCommands(int U) { from[t] = from[t - 1 - U]; ++t; } char GetLetter(int P) { int jump = depth[from[t - 1]] - 1 - P; int x = from[t - 1]; for (int i = 0; jump >> i; ++i) { if (jump >> i & 1) { x = anc[x][i]; } } return type[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...