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;
const int N=1e6,LG=20;
int it;
char tab[N+10];
int rt[N+10];
int jmp[N+10][LG+2];
int siz[N+10];
void Init()
{
it=0;
return;
}
void TypeLetter(char L)
{
it++;
tab[it]=L;
rt[it]=it;
siz[it]=siz[it-1]+1;
jmp[it][0]=rt[it-1];
for(int i=1;i<=LG;i++)
jmp[it][i]=jmp[jmp[it][i-1]][i-1];
return;
}
void UndoCommands(int U)
{
it++;
rt[it]=rt[it-U-1];
siz[it]=siz[it-U-1];
return;
}
char GetLetter(int P)
{
P=siz[it]-P-1;
int x=rt[it];
for(int i=0;i<=LG;i++)
{
if(P%2==1)
x=jmp[x][i];
P/=2;
}
return tab[x];
}
# | 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... |