Submission #194319

#TimeUsernameProblemLanguageResultExecution timeMemory
194319c4ts0upCrayfish scrivener (IOI12_scrivener)C++17
12 / 100
760 ms194724 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...