# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1036266 | stdfloat | Crayfish scrivener (IOI12_scrivener) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "grader.cpp"
using namespace std;
const int N = (int)1e6 + 1;
int q, cnt, cur;
vector<char> ch(N);
vector<int> num(N), pr(N), d(N);
void Init() {}
void TypeLetter(char L) {
num[++q] = ++cnt;
ch[cnt] = L;
pr[cnt] = cur;
d[cnt] = d[cur] + 1;
cur = cnt;
}
void UndoCommands(int U) {
q++;
num[q] = cur = num[q - U - 1];
}
char GetLetter(int P) {
P = d[cur] - P - 1;
int x = cur;
while (P--) x = pr[x];
return ch[x];
}