제출 #370023

#제출 시각아이디문제언어결과실행 시간메모리
370023penguinhackerKnjige (COCI20_knjige)C++14
0 / 50
5 ms1572 KiB
// source: https://oj.uz/problem/view/COCI20_knjige
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ar array

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int> v(n); for (int& i : v) cin >> i;
	vector<string> ans;
	for (int rep = 0; rep < n - 1; ++rep) {
		int pos = max_element(v.begin(), v.end()) - v.begin();
		vector<int> nv(v.begin(), v.begin() + pos);
		vector<int> t(v.begin() + pos + 1, v.end());
		nv.insert(nv.end(), t.begin(), t.end());
		for (int i = 0; i < pos; ++i) ans.push_back("UZMI L L"), ans.push_back("STAVI L R");
		ans.push_back("UZMI R L");
		for (int i = pos + 1; i < n - rep; ++i) ans.push_back("UZMI L L"), ans.push_back("STAVI L R");
		ans.push_back("STAVI R L");
		for (int i = 1; i < n - rep; ++i) ans.push_back("UZMI L R"), ans.push_back("STAVI L L");
		swap(v, nv);
	}
	cout << ans.size() << "\n";
	for (string s : ans) cout << s << "\n";
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...