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>
using namespace std;
const int N = (int)1e6 + 1;
int q, cnt, cur;
vector<char> ch(N);
vector<int> num(N), d(N);
vector<vector<int>> sp(N, vector<int>(20));
void Init() {}
void TypeLetter(char L) {
num[++q] = ++cnt;
ch[cnt] = L;
d[cnt] = d[cur] + 1;
sp[cnt][0] = cur;
for (int i = 1; i < 20; i++) sp[cnt][i] = sp[sp[cnt][i - 1]][i - 1];
cur = cnt;
}
void UndoCommands(int U) {
q++;
num[q] = cur = num[q - U - 1];
}
char GetLetter(int P) {
int x = cur;
for (int i = 19; i >= 0; i--) {
if (P < d[x] - (1 << i)) x = sp[x][i];
}
return ch[x];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |