# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
373247 | sam571128 | Knjige (COCI20_knjige) | C++14 | 4 ms | 1124 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>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
signed main(){
fastio
int n;
cin >> n;
multiset<int> s;
int arr[n];
stack<int> st, st2;
for(int i = 0;i < n;i++){
cin >> arr[i];
s.insert(arr[i]);
}
for(int i = n-1;~i;i--) st.push(arr[i]);
vector<pair<string,pair<char,char>>> v;
while(!st.empty()){
if(st.top()!=*s.begin()){
v.push_back({"UZMI",{'L','L'}});
v.push_back({"STAVI",{'L','D'}});
st2.push(st.top());
st.pop();
}else{
v.push_back({"UZMI",{'D','L'}});
s.erase(s.find(st.top()));
st.pop();
while(!st2.empty()){
v.push_back({"UZMI",{'L','D'}});
v.push_back({"STAVI",{'L','L'}});
st.push(st2.top());
st2.pop();
}
v.push_back({"STAVI",{'D','D'}});
}
}
for(int i = 0;i < n;i++){
v.push_back({"UZMI",{'L','D'}});
v.push_back({"STAVI",{'L','L'}});
}
cout << v.size() << "\n";
for(auto p : v){
cout << p.first << " " << p.second.first << " " << p.second.second << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |