This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
int cnt, cnt2, par[20][1000001], A[1000001], dep[1000001];
char S[1000001];
void Init() {
}
void TypeLetter(char L) {
++cnt2;
S[cnt2] = L;
dep[cnt2] = dep[A[cnt]] + 1;
par[0][cnt2] = A[cnt];
for (int i = 1; i < 20; ++i) par[i][cnt2] = par[i - 1][par[i - 1][cnt2]];
++cnt;
A[cnt] = cnt2;
}
void UndoCommands(int U) {
int x = cnt - U;
++cnt;
A[cnt] = A[x];
}
char GetLetter(int P) {
int x = A[cnt];
for (int i = 0; i < 20; ++i) if (((dep[x] - P - 1) >> i) & 1) {
x = par[i][x];
}
return S[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... |