# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1006546 | 2024-06-24T02:58:08 Z | vjudge1 | Knjige (COCI20_knjige) | C++17 | 29 ms | 1492 KB |
#include<bits/stdc++.h> using namespace std; const int N = 105; vector<int> a; string space = " ", take = "UZMI", put = "STAVI", lft = "L", rht = "D"; vector<string> sol; int n; void SORT(vector<int> v) { if(v.size() == 1) { sol.push_back(take + space + lft + space + rht); sol.push_back(put + space + lft + space + lft); return; } vector<int> vp; int l = v.back(); sol.push_back(take + space + lft + space + rht); for(int j = v.size() - 2; j >= 0; j--) { sol.push_back(take + space + rht + space + rht); int r = v[j]; if(l < r) { vp.push_back(l); sol.push_back(put + space + lft + space + lft); sol.push_back(put + space + rht + space + lft); sol.push_back(take + space + lft + space + lft); l = r; } else { vp.push_back(r); sol.push_back(put + space + rht + space + lft); } } for(int i = 0; i < vp.size(); i++) { sol.push_back(take + space + rht + space + lft); sol.push_back(put + space + rht + space + rht); } sol.push_back(put + space + lft + space + lft); reverse(vp.begin(), vp.end()); SORT(vp); } int main() { cin >> n; a.resize(n); for(int i = 0; i < n; i ++) cin >> a[i]; for(int i = 0; i < n; i ++) { sol.push_back(take); sol.back() += space + lft + space + lft; sol.push_back(put); sol.back() += space + lft + space + rht; } SORT(a); cout << sol.size() << endl; for(auto s : sol) cout << s << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 1488 KB | Output is correct |
2 | Correct | 24 ms | 1488 KB | Output is correct |
3 | Correct | 24 ms | 1492 KB | Output is correct |
4 | Correct | 26 ms | 1492 KB | Output is correct |
5 | Correct | 26 ms | 1488 KB | Output is correct |
6 | Correct | 25 ms | 1488 KB | Output is correct |
7 | Correct | 21 ms | 1488 KB | Output is correct |
8 | Correct | 25 ms | 1488 KB | Output is correct |
9 | Correct | 29 ms | 1492 KB | Output is correct |
10 | Correct | 21 ms | 1488 KB | Output is correct |