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>
const int MAX_N = 1000000;
const int MAX_L = 20;
struct Node {
char letter;
int depth;
int goup[MAX_L];
} tree[1+MAX_N];
int top = 1;
void Init() {
tree[0] = {'\0', -1};
for(int i = 0; i < MAX_L; ++i)
tree[0].goup[i] = 0;
}
void TypeLetter(char L) {
tree[top].goup[0] = top - 1;
for(int i = 1; i < MAX_L; ++i)
tree[top].goup[i] = tree[tree[top].goup[i - 1]].goup[i - 1];
// this line is way too long JfC
tree[top].depth = tree[top - 1].depth + 1;
tree[top].letter = L;
++top;
}
void UndoCommands(int U) {
tree[top] = tree[top - 1 - U];
top++;
}
char GetLetter(int P) {
int nod = top - 1;
for(int i = MAX_L - 1; i >= 0; --i) {
int nod2 = tree[nod].goup[i];
if(tree[nod2].depth >= P)
nod = nod2;
}
return tree[nod].letter;
}
# | 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... |