# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
542013 | AlperenT | Knjige (COCI20_knjige) | C++17 | 2 ms | 984 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |