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>
#define debug(...) //fprintf(stderr, __VA_ARGS__)
using namespace std;
const int LOG = 20;
const int N = 1 << LOG;
char c[N]; // = {'*'};
int nov = 1, up[N][LOG], dep[N], pos[N], lst;
char climb(int u, int x) {
for(int i = LOG - 1; i >= 0; --i) {
if(x & (1 << i)) {
u = up[u][i];
}
}
return c[u];
}
void Init() {}
void TypeLetter(char L) {
up[nov][0] = pos[lst];
for(int i = 1; i < LOG; ++i) {
up[nov][i] = up[up[nov][i - 1]][i - 1];
}
dep[nov] = dep[pos[lst]] + 1;
c[nov] = L;
pos[++lst] = nov++;
}
void UndoCommands(int U) {
++lst;
pos[lst] = pos[lst - U - 1];
}
char GetLetter(int P) {
return climb(pos[lst], dep[pos[lst]] - P - 1);
}
# | 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... |