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;
typedef long long ll;
const ll MAXN = 1e6 + 10;
const ll LOG = 20;
vector<int> vec;
int cur, par[MAXN][LOG], H[MAXN];
char F[MAXN];
void Init() {
cur = 0;
vec.push_back(cur);
}
void TypeLetter(char L) {
int v = int(vec.size());
F[v] = L;
H[v] = H[cur] + 1;
par[v][0] = cur;
cur = v;
vec.push_back(cur);
for (int i = 1; i < LOG; i++)
par[v][i] = par[par[v][i - 1]][i - 1];
}
void UndoCommands(int U) {
cur = vec[int(vec.size()) - 1 - U];
vec.push_back(cur);
}
char GetLetter(int P) {
int k = H[cur] - P - 1;
int v = cur;
for (int i = 0; i < LOG; i++)
if (k >> i & 1)
v = par[v][i];
return F[v];
}
# | 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... |