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>
#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];
}
# | 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... |