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 mx = 1e6 + 5;
const int lg = 20;
int D[mx], I[mx];
char X[mx];
int p[mx][lg];
int n;
void Init() {
}
void TypeLetter(char L) {
++n;
I[n] = n; X[n] = L;
p[n][0] = I[n-1];
D[n] = D[I[n-1]] + 1;
for(int j = 1; 1 << j <= D[n]; j++){
p[n][j] = p[p[n][j-1]][j-1];
}
}
void UndoCommands(int U) {
++n;
I[n] = I[n - 1 - U];
}
char GetLetter(int P) {
++P;
int b = I[n], dlt = D[b] - P;
for(int j = 0; j < lg; j++){
if(dlt >> j & 1) b = p[b][j];
}
return X[b];
}
# | 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... |