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<cmath>
char last;
void Init() {}
int t=-1,er[2000000],a[1000005][23];
char v[2000000];
void TypeLetter(char L)
{
t++;
if(t==0)
er[t]=1;
else
er[t]=er[t-1]+1;
v[t]=L;
for(int i=0;i<log2(er[t]);i++)
{
if(i==0)
a[t][0]=t-1;
else
a[t][i]=a[a[t][i-1]][i-1];
}
}
void UndoCommands(int U)
{
t++;
er[t]=er[t-U-1];
v[t]=v[t-U-1];
for(int i=0;i<log2(er[t]);i++)
a[t][i]=a[t-U-1][i];
}
char GetLetter(int P)
{
int p=er[t]-P-1;
int e=t;
while(p!=0)
{
e=a[e][int(log2(p))];
p-=pow(2,int(log2(p)));
}
return v[e];
}
# | 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... |