Submission #370024

#TimeUsernameProblemLanguageResultExecution timeMemory
370024penguinhackerKnjige (COCI20_knjige)C++14
50 / 50
5 ms1540 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 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 timeMemoryGrader output
Fetching results...