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 N=1e6+10, LG=20;
int dep[N], up[LG][N], node[N];
char a[N];
vector<int> g[N];
int cur, cnt;
void Init() {
cur=0, cnt=0;
}
void TypeLetter(char L) {
a[++cnt]=L;
g[cur].push_back(cnt);
dep[cnt]=dep[cur]+1;
up[0][cnt]=cur;
for (int k=1; k<LG; ++k) up[k][cnt]=up[k-1][up[k-1][cnt]];
cur=cnt;
node[cnt]=cur;
}
void UndoCommands(int U) {
++cnt;
cur=node[cnt-U-1];
node[cnt]=cur;
}
char GetLetter(int P) {
int d=dep[cur]-P-1;
int u=cur;
for (int k=0; k<LG; ++k) if (d>>k&1) u=up[k][u];
return a[u];
}
# | 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... |