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, int previous, int current_val) {
type = c;
p = previous;
x = current_val;
}
};
int idx = -1;
vector <char> curr;
vector <Instruction> Ins;
void Init() {
curr.resize(1e6+5);
for (int i=0; i<1e6+5; i++) curr[i] = '#';
}
void TypeLetter(char L) {
idx++;
char prev = curr[idx];
curr[idx] = L;
Ins.pb(Instruction('T', prev, L));
//cout << "ADDED: T " << prev << " " << L << endl;
}
void ReType(Instruction it) {
curr[idx] = it.p;
idx--;
Ins.pb(Instruction('R', it.x, it.p));
//cout << "ADDED: R " << it.x << " " << it.p << endl;
}
void UndoCommands(int u) {
int kons = Ins.size();
int cnt = 0;
for (int i=0; i<u; i++) {
Instruction act = Ins[kons-1-i-cnt];
// Type
if (act.type == 'T') ReType(act);
// Undo
else {
while (Ins[kons-1-i-cnt].type == 'R') TypeLetter(Ins[kons-1-i-cnt].p), cnt++;
}
}
}
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... |