This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
struct TYPE{
char num;
int next_0, lev, next[21];
} d[1000001];
int n, p[21];
void Init(){
p[0] = 1;
for (int i = 1; i <= 20; i++) p[i] = p[i - 1] * 2;
}
void TypeLetter(char x){
n++, d[n].next_0 = n, d[n].num = x, d[n].lev = d[n - 1].lev + 1;
d[n].next[0] = d[n - 1].next_0;
for (int i = 1; i <= 20; i++) d[n].next[i] = d[d[n].next[i - 1]].next[i - 1];
}
void UndoCommands(int x) {
n++, d[n].next_0 = d[n - x - 1].next_0, d[n].lev = d[d[n].next_0].lev;
}
char f(int x, int y){
if (x != d[x].next_0) return f(d[x].next_0, y);
if (y == 0) return d[x].num;
for (int i = 20; i >= 0; i--)
if (p[i] <= y) return f(d[x].next[i], y - p[i]);
}
char GetLetter(int x){
return f(n, d[n].lev - x - 1);
}
Compilation message (stderr)
scrivener.cpp: In function 'char f(int, int)':
scrivener.cpp:28:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |