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;
const int logN = 20;
const int N = 2e6 + 5;
static int depth[N], node, lca[N][logN+1], C, S, W[N];
char col[N];
void Init() {
}
void TypeLetter(char L) {
W[++S] = ++C;
col[C] = L;
lca[C][0] = node;
node = C;
for(int i = 1; i <= logN; i++)
lca[node][i] = lca[lca[node][i-1]][i-1];
depth[node] = depth[lca[node][0]] + 1;
}
void UndoCommands(int U) {
node = W[S - U];
W[++S] = node;
}
char GetLetter(int P) {
P = depth[node] - P - 1;
int tt = node;
for(int i = logN; i >= 0; i--)
if((1 << i) <= P) {
P -= (1 << i);
tt = lca[tt][i];
}
return col[tt];
}
# | 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... |