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 <vector>
#include <string>
using namespace std;
#define pb push_back
const int lg = 25;
struct node{
char val;
int idx;
vector<node*> pr;
node(char c){
val = c;
idx = 0;
pr.resize(25);
pr.assign(25, nullptr);
}
};
string res;
vector<node*> v;
void Init() {}
void TypeLetter(char l) {
node* cur = new node(l);
if (!v.empty()) {
cur->pr[0] = v.back();
cur->idx = cur->pr[0]->idx + 1;
}
for (int i = 1; i < lg; ++i){
if (cur->pr[i-1] == nullptr) break;
cur->pr[i] = cur->pr[i-1]->pr[i-1];
}
v.pb(cur);
}
void UndoCommands(int u) {
int n = v.size();
node* cur = v[n - u - 1];
v.pb(cur);
}
char GetLetter(int p) {
node* cur = v.back();
for (int i = lg - 1; i >= 0; --i){
if (cur->pr[i] != nullptr && cur->pr[i]->idx >= p){
cur = cur->pr[i];
}
}
return cur->val;
}
# | 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... |