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 last;
int p[1000010][25],a[1000010],pos[1000010],n,len[1000010];
char str[1000010];
void Init() {}
void TypeLetter(char L)
{
int i;
n++;
p[n][0]=pos[n-1];
for(i=1;i<=20;i++)
{
p[n][i]=p[p[n][i-1]][i-1];
}
pos[n]=n;
len[n]=len[p[n][0]]+1;
str[n]=L;
}
void UndoCommands(int U)
{
int i;
n++;
pos[n]=pos[n-U-1];
len[n]=len[pos[n]];
}
char GetLetter(int P)
{
int i;
int m,dir=pos[n];
m=len[n]-P-1;
for(i=0;i<=20;i++)
{
if(m&(1<<i))
{
m-=(1<<i);
dir=p[dir][i];
}
}
return str[dir];
}
# | 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... |