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;
int t[N][26], p[N][21], idx, d[N];
int tym, node[N];
char c[N];
void Init() {}
void TypeLetter(char L) {
int u = node[tym];
int &v = t[u][L - 'a'];
if(!v) {
v = ++idx;
p[v][0] = u;
for(int i = 1; i <= 20; i++)
p[v][i] = p[p[v][i - 1]][i - 1];
} c[v] = L;
node[++tym] = v;
d[v] = d[u] + 1;
}
void UndoCommands(int U) {
int u = node[tym - U];
node[++tym] = u;
}
char GetLetter(int P) {
int u = node[tym];
int k = d[u] - P - 1;
for(int i = 20; i >= 0; i--)
if(k >> i & 1) u = p[u][i];
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... |