이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |