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>
int nr;
struct state {
char letter;
int length, p[20];
} s[1000001];
void Init() {}
void TypeLetter(char L) {
s[nr + 1] = {L,s[nr].length + 1, nr};
++nr;
for (int i = 1; i < 20; ++i)
s[nr].p[i] = s[s[nr].p[i - 1]].p[i - 1];
}
void UndoCommands(int U) {
s[nr + 1] = s[nr - U];
++nr;
}
char GetLetter(int P) {
int cur = nr;
P = s[cur].length - 1 - P;
for (int i = 0; i < 20; ++i)
if (P & (1 << i))
cur = s[cur].p[i];
return s[cur].letter;
}
# | 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... |