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 <iostream>
int const nmax = 1000000;
using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
char last;
int far[20][1 + nmax], ptr = 0;
int level[1 + nmax];
char chr[1 + nmax];
void Init() {}
void TypeLetter(char L) {
++ptr;
far[0][ptr] = ptr - 1;
for(int h = 1; h < 20; h++)
far[h][ptr] = far[h - 1][far[h - 1][ptr]];
level[ptr] = level[ptr - 1] + 1;
chr[ptr] = L;
}
void UndoCommands(int U) {
++ptr;
far[0][ptr] = far[0][ptr - 1 - U];
for(int h = 1; h < 20; h++)
far[h][ptr] = far[h - 1][far[h - 1][ptr]];
level[ptr] = level[ptr - 1 - U];
chr[ptr] = chr[ptr - 1 - U];
}
char GetLetter(int P) {
int target = level[ptr] - 1 - P;
int pos = ptr;
for(int h = 19; 0 <= h; h--)
if((target & (1 << h)))
pos = far[h][pos];
return chr[pos];
}
# | 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... |