제출 #195647

#제출 시각아이디문제언어결과실행 시간메모리
195647c4ts0up크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
12 / 100
1097 ms223584 KiB
#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() { 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 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...