Submission #542012

#TimeUsernameProblemLanguageResultExecution timeMemory
542012AlperenTKnjige (COCI20_knjige)C++17
0 / 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 R R"); b = rght.top(); rght.pop(); ans.push_back("STAVI R L"); lft.push(b); b = -1; } ans.push_back("STAVI L R"); rght.push(a); a = -1; } while(!rght.empty()){ ans.push_back("UZMI L R"); 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...