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 <cstdio>
const int maxn = 1e5+10;
int state[maxn], parent[maxn][25];
int depth[maxn]; char letter[maxn];
int stat = 0, command = 0;
void Init() {}
void TypeLetter(char L) {
stat++, command++;
state[command] = stat;
letter[stat] = L;
int par = state[command - 1];
depth[stat] = depth[par] + 1;
parent[stat][0] = par;
letter[stat] = L;
for(int i = 1; i <= 19; i++)
parent[stat][i] = parent[parent[stat][i-1]][i-1];
}
void UndoCommands(int U) {
command++;
state[command] = state[command - U - 1];
}
char GetLetter(int P) {
int cur = state[command];
P = depth[cur] - P - 1;
for(int i = 0; i <= 19; i++)
if(P & (1 << i))
cur = parent[cur][i];
return letter[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... |