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>
using namespace std;
int up[1000005][20],depth[1000005],pos[1000005],timer,tmp,v,i;
char res[1000005];
void Init(){}
void TypeLetter(char ch){
res[++v]=ch;
up[v][0]=tmp;
depth[v]=depth[tmp]+1;
tmp=v;
pos[++timer]=tmp;
for(i=1;i<20;i++)up[tmp][i]=up[up[tmp][i-1]][i-1];
}
void UndoCommands(int num){
tmp=pos[timer-num];
timer++;
pos[timer]=tmp;
}
char GetLetter(int p){
p++;
int to=tmp;
for(i=19;i>=0;i--)if(depth[up[to][i]]>=p)to=up[to][i];
return res[to];
}
# | 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... |