#include <bits/stdc++.h>
using namespace std;
#ifndef wambule
// #include ".h"
#else
#endif
const int L = 20;
int dg;
// in loving memory of the deceased structure
vector<pair<pair<char, int>, vector<int>>> ilm;
vector<int> v;
void Init() {
dg = 0;
ilm.clear();
ilm.push_back({{' ', -1}, vector<int>(L, -1)});
}
void TypeLetter(char c) {
int x = ilm.size();
ilm.push_back({{c, ilm[dg].first.second + 1}, vector<int>(L, -1)});
ilm[x].second[0] = dg;
for(int i = 1; i < L; ++i) {
ilm[x].second[i] = ilm[x].second[i - 1];
if(ilm[x].second[i] != -1) ilm[x].second[i] = ilm[ilm[x].second[i]].second[i - 1];
}
dg = x;
v.push_back(dg);
}
void UndoCommands(int x) {
dg = v[(int)v.size() - 1 - x];
v.push_back(dg);
}
char GetLetter(int id) {
int x = dg;
for(int i = L - 1; i >= 0; --i) {
if(ilm[x].second[i] != -1 && ilm[ilm[x].second[i]].first.second >= id) {
x = ilm[x].second[i];
}
}
#ifdef wambule
cout << "[:] " << ilm[x].first.first << endl;
#endif
return ilm[x].first.first;
}
#ifdef wambule
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
Init();
TypeLetter('a');
TypeLetter('b');
GetLetter(1);
TypeLetter('d');
UndoCommands(2);
UndoCommands(1);
GetLetter(2);
TypeLetter('e');
UndoCommands(1);
UndoCommands(5);
TypeLetter('c');
GetLetter(2);
UndoCommands(2);
GetLetter(2);
return 0;
}
#endif
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
508 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
2 ms |
620 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
2 ms |
748 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
2 ms |
876 KB |
Output is correct |
7 |
Correct |
2 ms |
764 KB |
Output is correct |
8 |
Correct |
2 ms |
748 KB |
Output is correct |
9 |
Correct |
2 ms |
748 KB |
Output is correct |
10 |
Correct |
2 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
735 ms |
85348 KB |
Output is correct |
2 |
Correct |
765 ms |
85628 KB |
Output is correct |
3 |
Correct |
583 ms |
85544 KB |
Output is correct |
4 |
Correct |
564 ms |
64900 KB |
Output is correct |
5 |
Correct |
749 ms |
85764 KB |
Output is correct |
6 |
Correct |
660 ms |
90828 KB |
Output is correct |
7 |
Correct |
649 ms |
44232 KB |
Output is correct |
8 |
Correct |
572 ms |
66348 KB |
Output is correct |
9 |
Correct |
879 ms |
92508 KB |
Output is correct |
10 |
Correct |
350 ms |
67364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1039 ms |
64672 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |