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 depth[1000003];
char ch[1000003];
int pa[1000003][20];
int id[1000003];
int T, top;
void Init() { ch[T = 0] = '^'; depth[0] = -1; top = 1; }
void TypeLetter(char p) {
depth[top] = depth[pa[top][0] = id[T++]] + 1;
for (int i = 1; ch[pa[top][i - 1]] != '^'; i++) pa[top][i] = pa[pa[top][i - 1]][i - 1];
ch[id[T] = top++] = p;
}
void UndoCommands(int m) { id[T + 1] = id[T - m]; T++; }
char GetLetter(int m) {
int now = id[T], a = depth[id[T]] - m;
for (int i = 0, p = 1; a; i++, p <<= 1)
if (p & a) now = pa[now][i], a ^= p;
return ch[now];
}
# | 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... |