This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define MAXN 2000003
#include "bits/stdc++.h"
using namespace std;
const int LOGN=21;
int nd, now, P[MAXN][LOGN], lvl[MAXN];
vector<int> where;
char arr[MAXN];
void Init() {}
char get(int x){
int tmp = now;
for(int i = LOGN-1; i>=0; i--)
if (x >= (1<<i))
tmp = P[tmp][i], x -= (1<<i);
return arr[tmp];
}
void TypeLetter(char L) {
int to = ++nd;
arr[to] = L;
P[to][0] = now;
lvl[to] = lvl[now]+1;
now = nd;
for(int i=1;i<LOGN;i++)
if(P[now][i-1])
P[now][i]=P[P[now][i-1]][i-1];
where.push_back(now);
}
void UndoCommands(int U) {
now = where[int(where.size())-U-1];
where.push_back(now);
}
char GetLetter(int P) {
return get(lvl[now]-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... |