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;
array<node*, 22> par;
int len;
};
typedef node* pnode;
pnode cur;
vector<pnode> undo;
void Init() {
cur = new node();
cur->len = -1;
undo.push_back(cur);
}
void TypeLetter(char L) {
pnode tmp = new node();
tmp->par[0] = cur;
for (int i = 1; i < 22; i++) {
if(tmp->par[i - 1] == NULL) break;
tmp->par[i] = tmp->par[i - 1]->par[i - 1];
}
tmp->c = L;
tmp->len = cur->len + 1;
cur = tmp;
undo.push_back(cur);
}
void UndoCommands(int U) {
pnode tmp = undo[undo.size() - U - 1];
cur = tmp;
undo.push_back(cur);
}
char GetLetter(int P) {
pnode tmp = cur;
int x = tmp->len - P;
for (int i = 0; i < 22; i++) {
if(x & (1 << i)){
tmp = tmp->par[i];
}
}
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... |