This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
char ops[1000005];
int prev[1000005][20], size[1000005], sz;
int go[1000005];
void Init(){
sz = 1;
}
void TypeLetter(char L){
int p = sz;
go[p] = p;
ops[p] = L;
if(p)prev[p][0]=go[p-1];
for(int i=1;prev[p][i-1];i++)
prev[p][i] = prev[prev[p][i-1]][i-1];
size[p]=size[go[p-1]]+1;
sz++;
}
void UndoCommands(int U){
go[sz]=go[sz-U-1];
sz++;
}
char GetLetter(int P){
int pos = go[sz-1];
int o = P+1;
for(int i=19;i>=0;i--)
if(size[prev[pos][i]]>=o)
pos = prev[pos][i];
return ops[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... |