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;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
struct node {
char c;
node* par;
int len;
vector<pair<node*, int>> undo;
};
typedef node* pnode;
pnode root;
pnode cur;
void Init() {
root = new node();
root->len = -1;
cur = root;
}
void TypeLetter(char L) {
pnode tmp = new node();
tmp->par = cur;
tmp->undo.push_back({cur, cur->undo.size() - 1});
tmp->c = L;
tmp->len = cur->len + 1;
cur = tmp;
}
void UndoCommands(int U) {
pnode tmp = cur;
int b = tmp->undo.size() - 1;
while(U--){
int tb = tmp->undo[b].second;
tmp = tmp->undo[b].first;
b = tb;
}
tmp->undo.push_back({cur, cur->undo.size() - 1});
cur = tmp;
}
char GetLetter(int P) {
pnode tmp = cur;
while(tmp->len > P){
tmp = tmp->par;
}
return tmp->c;
}
# | 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... |