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>
using namespace std;
int n = 0;
const int maxn = 1e6+5;
int st[20][maxn];
char C[maxn];
int dep[maxn], prv[maxn];
void Init() {
n = 0;
}
void TypeLetter(char L) {
n++;
C[n] = L;
prv[n] = n;
dep[n] = dep[prv[n-1]] + 1;
st[0][n] = prv[n-1];
for(int i = 1; i < 20; i++){
st[i][n] = st[i-1][st[i-1][n]];
}
}
void UndoCommands(int U) {
n++;
prv[n] = prv[n - U - 1];
}
char GetLetter(int P) {
int id = prv[n], d = dep[id] - (P + 1);
for(int i = 0; i < 20; i++){
if(d&(1<<i))id = st[i][id];
}
return C[id];
}
# | 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... |