This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
const int MX = 1000010;
char p[MX];
int up[MX][20],a[MX],cnt,dep[MX];
void Init(){dep[0]=-1;}
void TypeLetter(char L){
++cnt;
p[cnt]=L;
a[cnt]=cnt;
up[cnt][0]=a[cnt-1];
dep[cnt]=dep[a[cnt-1]]+1;
int i,tmp=up[cnt][0];
for(i=1;i<20;i++){
if(up[tmp][i-1]){
up[cnt][i]=up[tmp][i-1];
tmp=up[cnt][i];
}
else break;
}
}
void UndoCommands(int U){
a[cnt+1]=a[cnt-U];
cnt++;
}
char GetLetter(int P){
int i,tmp=a[cnt];
for(i=19;i>=0;i--){
if(dep[up[tmp][i]]<P)continue;
tmp=up[tmp][i];
}
return p[tmp];
}
# | 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... |