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 mxN = 1000005;
char s[mxN];
int bin[20][mxN], depth[mxN], it = 1;
vector<int> tail = {0};
void Init() {
}
void TypeLetter(char c) {
s[++it] = c;
depth[it] = depth[tail.back()] + 1;
bin[0][it] = tail.back();
for (int i = 1; i < 20; i++) {
bin[i][it] = bin[i-1][bin[i-1][it]];
}
tail.push_back(it);
}
void UndoCommands(int k) {
tail.push_back(tail[tail.size()-k-1]);
}
char GetLetter(int k) {
int ret = tail.back();
for (int i = 0; i < 20; i++) {
if ((1 << i) & depth[tail.back()-k-1]) ret = bin[i][ret];
}
return s[ret];
}
# | 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... |