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 n=0,a[1000069],pr[1000069][20],dh[1000069];
void bd()
{
int i;
for(i=1;i<20;i++)
{
pr[n][i]=pr[pr[n][i-1]][i-1];
}
}
void Init()
{
}
void TypeLetter(char ch)
{
n++;
a[n]=ch-'a';
pr[n][0]=n-1;
dh[n]=dh[n-1]+1;
bd();
}
void UndoCommands(int x)
{
n++;
pr[n][0]=n-1-x;
dh[n]=dh[n-1-x];
bd();
}
char GetLetter(int x)
{
int i,p=n;
x++;
for(i=19;i+1;i--)
{
if(dh[pr[p][i]]>=x)
{
p=pr[p][i];
}
}
return (char)(a[p]+'a');
}
# | 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... |