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 nx=1e6+5, mx=20;
int p[nx][mx], t, c[nx], cur, sz[nx];
vector<int> v;
void Init() {
}
void TypeLetter(char L) {
t++; p[t][0]=cur; sz[t]=sz[cur]+1;
for (int i=1; i<mx; i++) p[t][i]=p[p[t][i-1]][i-1];
cur=t; c[cur]=L; v.push_back(cur);
}
void UndoCommands(int U) {
cur=v[max((int) v.size()-U-1, 0)];
v.push_back(cur);
}
char GetLetter(int P) {
int k=sz[cur]-P-1, tmp=cur;
for (int i=0; i<mx; i++) if (k&(1<<i)) tmp=p[tmp][i];
return c[tmp];
}
# | 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... |