Submission #445510

#TimeUsernameProblemLanguageResultExecution timeMemory
445510grtKnjige (COCI20_knjige)C++17
50 / 50
2 ms472 KiB
#include <bits/stdc++.h> #define ST first #define ND second #define PB push_back using namespace std; using ll = long long; using pi = pair<int,int>; using vi = vector<int>; const int nax = 110; int n, d[nax]; vector<tuple<bool,bool,bool>>moves; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0; i < n; ++i) { cin >> d[i]; } int tp = 0; int cnt = 0; for(int step = 1; step <= n; ++step) { cnt = 0; vi ord; int target = 1000000; for(int i = tp; i < n; ++i) { target = min(target, d[i]); } while(d[tp] != target) { //cout << "UZMI L L\n"; ord.PB(d[tp]); moves.PB({0,0,0}); moves.PB({1,0,1}); cnt++; tp++; } moves.PB({0, 1, 0}); for(int i = 0; i < cnt; ++i) { moves.PB({0, 0, 1}); moves.PB({1, 0, 0}); } moves.PB({1, 1, 1}); tp -= (cnt - 1); //reverse(ord.begin(), ord.end()); for(int i = tp; i < tp + cnt; ++i) { d[i] = ord[i - tp]; } } for(int i = 0; i < n; ++i) { moves.PB({0, 1, 1}); moves.PB({1, 1, 0}); } cout << (int)moves.size() << "\n"; for(auto [x,y,z] : moves) { if(x) cout << "STAVI "; else cout << "UZMI "; if(y) cout << "D "; else cout << "L "; if(z) cout << "D "; else cout << "L "; cout << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...