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 up[1000005][24], dep[1000005], pos[1000005];
char bukva[1000005];
int cur, i, n;
void Init() {
n = 0;
pos[0] = 0;
dep[0] = -1;
for(int i = 0; i < 24; i++) up[0][i] = 0;
}
void TypeLetter(char L) {
++n;
pos[n] = n;
bukva[n] = L;
dep[n] = dep[pos[n-1]]+1;
up[n][0] = pos[n-1];
for(int i = 1; i < 24; i++) up[n][i] = up[up[n][i-1]][i-1];
}
void UndoCommands(int U) {
++n;
pos[n] = pos[n-1-U];
}
char GetLetter(int P) {
cur = pos[n];
for(int i = 23; i >=0; --i){
if(dep[up[cur][i]] >= P) cur = up[cur][i];
}
return bukva[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... |