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 "grader.h"
#include <bits/stdc++.h>
using namespace std;
const int N=1000006,LG=20;
int parPow[N][LG],comNd[N],strSz[N];
char nd[N];
int cur=1,indCom;
void Init() {}
void TypeLetter(char L) {
comNd[indCom+1]=cur;
parPow[cur][0]=comNd[indCom];
strSz[cur]=strSz[comNd[indCom]]+1;
for (int i=1;i<LG;i++){
parPow[cur][i]=parPow[parPow[cur][i-1]][i-1];
}
nd[cur]=L;
cur++;
indCom++;
//cout<<indCom<<endl;
}
void UndoCommands(int u) {
comNd[indCom+1]=comNd[indCom-u];
indCom++;
}
char GetLetter(int p) {
p=strSz[comNd[indCom]]-p-1;
//cout<<p<<endl;
int ans=comNd[indCom];
for (int i=LG-1;i>=0;i--){
if (p&(1<<i)){
p-=(1<<i);
ans=parPow[ans][i];
}
}
//cout<<nd[ans]<<" ";
return nd[ans];
}
# | 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... |