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 <iostream>
using namespace std;
const int MAXT=2e6+1;
const int LG=27;
int tm=1,par[MAXT][LG],len[MAXT],ct;
char cp[MAXT];
void Init()
{
}
void TypeLetter(char L)
{
cp[tm]=L;
len[tm]=len[tm-1]+1;
par[tm][0]=tm-1;
for(int j=1;j<LG;j++)
par[tm][j]=par[par[tm][j-1]][j-1];
tm++;
}
void UndoCommands(int U)
{
len[tm]=len[tm-U-1];
par[tm][0]=tm-U-1;
for(int j=0;(j+1)<LG;j++)
par[tm][j+1]=par[tm-U-1][j];
tm++;
}
char GetLetter(int P)
{
ct=tm-1;
for(int j=LG-1;j>=0;j--)
if(len[par[ct][j]]>P)
ct=par[ct][j];
return cp[ct];
}
# | 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... |