Submission #60698

#TimeUsernameProblemLanguageResultExecution timeMemory
60698aomeCrayfish scrivener (IOI12_scrivener)C++17
100 / 100
784 ms144416 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1000005; int cur; int cnt1, cnt2; int h[N]; int par[20][N]; int arr[N]; char a[N]; void Init() {} void TypeLetter(char L) { ++cnt1; par[0][cnt1] = cur, h[cnt1] = h[cur] + 1; cur = cnt1, a[cur] = L; for (int i = 1; i < 20; ++i) { par[i][cur] = par[i - 1][par[i - 1][cur]]; } arr[++cnt2] = cur; } void UndoCommands(int U) { cur = arr[cnt2 + 1] = arr[cnt2 - U]; ++cnt2; } char GetLetter(int P) { int pos = cur; int H = h[cur] - (P + 1); for (int i = 19; i >= 0; --i) { if (H >= (1 << i)) { H -= (1 << i), pos = par[i][pos]; } } return a[pos]; }
#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...