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;
using ll = long long;
ll Q;
ll P[1000005][22];
char C[1000005];
ll D[1000005];
ll n = 0, m = 0;
vector<ll> V;
void Init(){}
void TypeLetter(char c){
m++;
C[m] = c;
V.push_back(m);
D[m] = D[n] + 1;
P[m][0] = n;
for(ll j = 1; j < 22; j++){
P[m][j] = P[P[m][j - 1]][j - 1];
}
n = m;
}
void UndoCommands(int k){
n = V[V.size() - 1 - k];
V.push_back(n);
}
char GetLetter(int k){
k = D[n] - k - 1;
ll u = n;
for(ll j = 0; j < 22; j++){
if(k & (1 << j)){
u = P[u][j];
}
}
return C[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... |