#include <bits/stdc++.h>
#define pb push_back
using namespace std;
struct Instruction {
char type;
char p, x;
Instruction() {};
Instruction (char c, char previous, char current_val) {
type = c;
p = previous;
x = current_val;
}
};
int iab;
int idx;
int kons;
vector <char> curr;
vector <vector <Instruction > > Ins;
void UpIAB() {
iab++;
}
void Init() {
ios_base::sync_with_stdio(0);
cin.tie(0);
curr.resize(1e6+5);
for (int i=0; i<1e6+5; i++) curr[i] = '#';
Ins.resize(1e6+5);
iab = -1;
idx = -1;
kons = 0;
}
void TypeLetter(char L) {
idx++;
char prev = curr[idx];
curr[idx] = L;
UpIAB();
// cout << "Instruction of type " << 'T' << endl;
// cout << "Previous value of " << prev << endl;
// cout << "New value of " << L << endl;
Ins[iab].pb(Instruction('T', prev, L));
// cout << Ins[iab][0].type << " - " << Ins[iab][0].p << " - " << Ins[iab][0].x << endl;
kons++;
//cout << "ADDED: T " << prev << " " << L << endl;
}
void ReType(Instruction it) {
curr[idx] = it.p;
idx--;
UpIAB();
Ins[iab].pb(Instruction('R', it.x, it.p));
kons++;
//cout << "ADDED: R " << it.x << " " << it.p << endl;
}
void UndoCommands(int u) {
UpIAB();
// cout << "iab tiene valor de " << iab << endl;
for (int i=0; i<u; i++) {
// cout << "kons = " << kons << endl;
// cout << "i = " << i << endl;
// cout << "Revisando la bucket con indice " << kons-1-i << endl;
for (int j = Ins[kons-1-i].size()-1; j>-1 ; j--) {
Instruction it = Ins[kons-1-i][j];
// cout << "INIT: " << it.type << " - " << it.p << " - " << it.x << endl;
if (it.type == 'T') {
// ReType
curr[idx] = it.p;
idx--;
Ins[iab].pb(Instruction('R', it.x, it.p));
continue;
}
else {
// Type
idx++;
char prev = curr[idx];
curr[idx] = it.p;
Ins[iab].pb(Instruction('T', prev, curr[idx]));
continue;
}
}
}
kons++;
}
char GetLetter(int P) {
return curr[P];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
24828 KB |
Output is correct |
2 |
Correct |
28 ms |
24824 KB |
Output is correct |
3 |
Correct |
30 ms |
24840 KB |
Output is correct |
4 |
Correct |
28 ms |
24824 KB |
Output is correct |
5 |
Correct |
28 ms |
24824 KB |
Output is correct |
6 |
Correct |
33 ms |
24952 KB |
Output is correct |
7 |
Correct |
33 ms |
24824 KB |
Output is correct |
8 |
Correct |
29 ms |
24952 KB |
Output is correct |
9 |
Correct |
28 ms |
24824 KB |
Output is correct |
10 |
Correct |
28 ms |
24824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
24772 KB |
Output is correct |
2 |
Correct |
22 ms |
24824 KB |
Output is correct |
3 |
Correct |
27 ms |
24824 KB |
Output is correct |
4 |
Correct |
28 ms |
24824 KB |
Output is correct |
5 |
Correct |
28 ms |
24952 KB |
Output is correct |
6 |
Correct |
28 ms |
24824 KB |
Output is correct |
7 |
Correct |
28 ms |
24824 KB |
Output is correct |
8 |
Correct |
28 ms |
24824 KB |
Output is correct |
9 |
Correct |
28 ms |
24824 KB |
Output is correct |
10 |
Correct |
21 ms |
24824 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1048 ms |
198644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1066 ms |
200748 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1039 ms |
198152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |