Submission #373247

#TimeUsernameProblemLanguageResultExecution timeMemory
373247sam571128Knjige (COCI20_knjige)C++14
50 / 50
4 ms1124 KiB
#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 timeMemoryGrader output
Fetching results...