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 = 1234567;
const int LOG = 20;
int t, from[N], depth[N], anc[N][LOG];
char type[N];
void Init() {
t = 1;
}
void TypeLetter(char L) {
type[t] = L;
depth[t] = depth[from[t - 1]] + 1;
anc[t][0] = from[t - 1];
for (int i = 1; depth[t] >> i; ++i) {
anc[t][i] = anc[anc[t][i - 1]][i - 1];
}
from[t] = t;
++t;
}
void UndoCommands(int U) {
from[t] = from[t - 1 - U];
++t;
}
char GetLetter(int P) {
int jump = depth[from[t - 1]] - 1 - P;
int x = from[t - 1];
for (int i = 0; jump >> i; ++i) {
if (jump >> i & 1) {
x = anc[x][i];
}
}
return type[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... |