Submission #370024

# Submission time Handle Problem Language Result Execution time Memory
370024 2021-02-22T22:31:39 Z penguinhacker Knjige (COCI20_knjige) C++14
50 / 50
5 ms 1540 KB
// 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 D");
		ans.push_back("UZMI D L");
		for (int i = pos + 1; i < n - rep; ++i) ans.push_back("UZMI L L"), ans.push_back("STAVI L D");
		ans.push_back("STAVI D L");
		for (int i = 1; i < n - rep; ++i) ans.push_back("UZMI L D"), ans.push_back("STAVI L L");
		swap(v, nv);
	}
	cout << ans.size() << "\n";
	for (string s : ans) cout << s << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1520 KB Output is correct
2 Correct 5 ms 1520 KB Output is correct
3 Correct 4 ms 1520 KB Output is correct
4 Correct 4 ms 1540 KB Output is correct
5 Correct 4 ms 1524 KB Output is correct
6 Correct 4 ms 1520 KB Output is correct
7 Correct 4 ms 1516 KB Output is correct
8 Correct 4 ms 1520 KB Output is correct
9 Correct 4 ms 1520 KB Output is correct
10 Correct 4 ms 1520 KB Output is correct