Submission #542013

#TimeUsernameProblemLanguageResultExecution timeMemory
542013AlperenTKnjige (COCI20_knjige)C++17
50 / 50
2 ms984 KiB
#include <bits/stdc++.h> using namespace std; const int N = 100 + 5; int t, n, arr[N], a = -1, b = -1; stack<int> lft, rght; vector<string> ans; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); cin >> n; for(int i = 1; i <= n; i++) cin >> arr[i]; for(int i = n; i >= 1; i--) lft.push(arr[i]); while(!lft.empty()){ ans.push_back("UZMI L L"); a = lft.top(); lft.pop(); while(!rght.empty() && rght.top() > a){ ans.push_back("UZMI D D"); b = rght.top(); rght.pop(); ans.push_back("STAVI D L"); lft.push(b); b = -1; } ans.push_back("STAVI L D"); rght.push(a); a = -1; } while(!rght.empty()){ ans.push_back("UZMI L D"); a = rght.top(); rght.pop(); ans.push_back("STAVI L L"); lft.push(a); } cout << ans.size() << "\n"; for(auto str : ans) cout << str << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...