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 par[1000005][20], len[1000005], n;
char c[1000005];
void Init()
{
}
void TypeLetter(char L)
{
n++;
c[n]=L;
len[n]=len[n-1]+1;
par[n][0]=n-1;
for (int i=1; i<20; i++)
par[n][i]=par[par[n][i-1]][i-1];
}
void UndoCommands(int U)
{
n++;
c[n]=c[n-U-1];
len[n]=len[n-U-1];
for (int i=0; i<20; i++)
par[n][i]=par[n-U-1][i];
}
char GetLetter(int P)
{
int cur=n, diff=len[n]-P-1;
for (int i=0; i<20; i++)
if (diff&(1<<i))
cur=par[cur][i];
return c[cur];
}
# | 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... |