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 <algorithm>
#include <vector>
#define M 1000000
using namespace std;
struct Node{
char c;
int h;
Node *nxt;
Node *par[25];
int tp;
};
Node *a[M+1];
int t;
void Init() {
a[t=0]=new Node();
}
void TypeLetter(char L) {
a[t]->nxt=a[t+1]=new Node();
a[t+1]->c=L;
a[t+1]->h=a[t]->h+1;
Node *p=a[t];
while(p){
a[t+1]->par[a[t+1]->tp++]=p;
p=p->tp>=a[t+1]->tp ? p->par[a[t+1]->tp-1] : NULL;
}
t++;
}
void UndoCommands(int U) {
a[t+1]=a[t-U];
t++;
}
char GetLetter(int P) {
Node *p=a[t];
P=p->h-P-1;
for(int i=0;P;i++){
if((1<<i)&P){
P-=(1<<i);
p=p->par[i];
}
}
return p->c;
}
# | 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... |