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>
#define MAXN 1000007
#define MAXL 22
int p[MAXL][MAXN],sz,l[MAXN],brp,d[MAXN];
char t[MAXN];
void Init() {sz++;}
void TypeLetter(char L)
{
l[++brp]=sz;
t[sz]=L;
d[sz]=d[l[brp-1]]+1;
p[0][sz]=l[brp-1];
for(int i=1;i<MAXL;i++) p[i][sz]=p[i-1][p[i-1][sz]];
sz++;
}
void UndoCommands(int U) {l[brp+1]=l[brp-U]; brp++;}
char GetLetter(int P)
{
int kp=d[l[brp]]-P-1,cur=l[brp];
while(kp!=0) {int x=(kp&-kp); cur=p[__builtin_popcount(x-1)][cur]; kp-=x;}
return t[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... |