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 node[1000006];
int NEXT_FREE_INDEX=1;
int n=1;
int lv[1000006];
char letter[1000006];
int ancestor[21][1000006];
int len;
int cont=0;
void Init() {
len=-1;
lv[0]=-1;
}
void TypeLetter(char L) {
int u=NEXT_FREE_INDEX++; //Last created node
node[n]=u;
lv[u]=lv[ node[n-1] ]+1;
letter[u]=L;
ancestor[0][u]=node[n-1];
for(int i=1;i<=20;i++){
ancestor[i][u]=ancestor[i-1][ ancestor[i-1][u] ];
}
n++;
}
void UndoCommands(int U) {
node[n]=node[n-U-1];
n++;
}
char GetLetter(int P) {
int u=node[n-1];
int d=lv[u]-P;
for(int i=20;i>=0;i--){
if(d & (1<<i)){
u=ancestor[i][u];
}
}
return letter[u];
}
# | 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... |