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 tcnt;
int path[1000010],top,cur;
int T[1000010][21],dep[1000010];
char ch[1000010];
void Init() {}
void TypeLetter(char L) {
tcnt++;
T[tcnt][0]=cur;
dep[tcnt]=dep[cur]+1;
int i;
for(i=1;i<21;i++)
T[tcnt][i]=T[T[tcnt][i-1]][i-1];
ch[tcnt]=L;
cur=tcnt;
path[++top]=cur;
}
void UndoCommands(int U) {
cur=path[top-U];
path[++top]=cur;
}
int kth(int u,int k) {
int i;
for(i=0;k;i++,k>>=1)
if(k&1)u=T[u][i];
return u;
}
char GetLetter(int P) {
return ch[kth(cur,dep[cur]-P-1)];
}
# | 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... |