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 <bits/stdc++.h>
const int M = 1e6+5;
int pos = 1;
int parent[M];
int lift[M][20],depth[M];
char lett[M];
void Init(){
}
void TypeLetter(char L){
int curr = pos;
parent[curr] = pos;
lett[curr] = L;
if(curr)lift[curr][0] = parent[curr-1];
for(int i=1;lift[curr][i-1];i++){
lift[curr][i] = lift[lift[curr][i-1]][i-1];
}
depth[curr] = depth[lift[curr][0]]+1;
pos++;
}
void UndoCommands(int U){
parent[pos] = parent[pos-U-1];
pos++;
}
char GetLetter(int P){
int curr = parent[pos-1];
for(int i=19;i>=0;i--){
if(depth[lift[curr][i]]>= P+1){
curr = lift[curr][i];
}
}
return lett[curr];
}
# | 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... |