Submission #382348

#TimeUsernameProblemLanguageResultExecution timeMemory
382348aarrCrayfish scrivener (IOI12_scrivener)C++14
0 / 100
398 ms70380 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1000 * 1000 + 5, LG = 21; char last = 0; int ind = 0; string s = ""; int sz[N]; int pos[N]; char c[N]; int par[N][LG]; void Init() { for (int i = 0; i < N; i++) { pos[i] = i; } } void TypeLetter(char L) { ind++; sz[ind] = sz[ind - 1]; c[ind] = L; pos[ind] = ind; par[ind][0] = pos[ind - 1]; for (int j = 1; j < LG; j++) { par[ind][j] = par[par[ind][j - 1]][j - 1]; } } void UndoCommands(int U) { ind++; pos[ind] = pos[ind - U - 1]; sz[ind] = sz[ind - U - 1]; } char GetLetter(int P) { int v = pos[ind]; int k = sz[ind] - P - 1; for (int j = LG - 1; j >= 0; j--) { if (k > (1 << j)) { v = par[v][j]; k -= 1 << j; } } return c[v]; }
#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...