Submission #395450

#TimeUsernameProblemLanguageResultExecution timeMemory
395450MrRobot_28Knjige (COCI20_knjige)C++17
50 / 50
3 ms976 KiB
#include<bits/stdc++.h> using namespace std; #define X first #define Y second #define sz(a) (int)a.size() #define ll long long #define ld long double signed main() { //ifstream cin("286.txt"); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector <int> d(n); for(int i = 0; i < n; i++) { cin >> d[i]; } vector <string> ans; vector <int> mass; for(int i = 0; i < n; i++) { ans.push_back("UZMI L L"); int cnt = 0; vector <int> t; while(sz(mass) > 0 && mass.back() > d[i]) { cnt++; ans.push_back("UZMI D D"); t.push_back(mass.back()); ans.push_back("STAVI D L"); mass.pop_back(); } ans.push_back("STAVI L D"); mass.push_back(d[i]); while(cnt--) { mass.push_back(t.back()); t.pop_back(); ans.push_back("UZMI D L"); ans.push_back("STAVI D D"); } } while(n--) { ans.push_back("UZMI D D"); ans.push_back("STAVI D L"); } cout << sz(ans) << "\n"; for(auto s : ans) cout << s << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...