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 nr;
int d[20][1000003], pos[1000003], num[1000003];
char s[1000003];
void Init() {}
void TypeLetter(char c) {
nr++;
s[nr] = c;
pos[nr] = nr;
num[nr] = 1 + num[nr - 1];
d[0][nr] = pos[nr - 1];
for(int ii = 1; ii < 20; ii++){
d[ii][nr] = d[ii - 1][ d[ii - 1][nr] ];
}
}
void UndoCommands(int x){
nr++;
pos[nr] = pos[nr - x - 1];
num[nr] = num[nr - x - 1];
for(int ii = 0; ii < 20; ii++){
d[ii][nr] = d[ii][ pos[nr] ];
}
}
char GetLetter(int p) {
int ii, x = pos[nr];
p = num[nr] - p - 1;
for(ii = 19; ii >= 0; ii--){
if(p >= (1 << ii) ){
x = d[ii][x];
p -= (1 << ii);
}
}
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... |