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;
typedef long long ll;
const int N=1000000;
int nodes=0;
char c[N+1];
int depth[N];
int p[N+1][20];
int cnt=0;
int pos[N+1];
void Init(){}
void TypeLetter(char L)
{
cnt++;
int a=pos[cnt-1];
int to=++nodes;
depth[to]=depth[a]+1;
p[to][0]=a;
for(int i=1;i<20;i++) p[to][i]=p[p[to][i-1]][i-1];
pos[cnt]=to;
c[to]=L;
}
void UndoCommands(int U)
{
cnt++;
pos[cnt]=pos[cnt-U-1];
}
char GetLetter(int P)
{
P++;
int a=pos[cnt];
for(int i=19;i>=0;i--) if(depth[p[a][i]]>=P) a=p[a][i];
return c[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... |