제출 #707446

#제출 시각아이디문제언어결과실행 시간메모리
707446Chal1shkanKnjige (COCI20_knjige)C++14
0 / 50
2 ms980 KiB
# include <bits/stdc++.h> # define pb push_back # define ff first # define ss second # define nl "\n" # define sz(x) ((int)(x).size()) # define deb(x) cerr << #x << " = " << x << endl; # define pll pair <ll, ll> typedef long long ll; typedef unsigned long long ull; typedef long double ld; const ll maxn = 2e5 + 25; const ll inf = 2e9 + 0; const ll mod = 1e9 + 123; const ll dx[] = {-1, 1, 0, 0}; const ll dy[] = {0, 0, -1, 1}; using namespace std; int n; void ma1n (/* SABR */) { cin >> n; multiset <int> qw; deque <int> q1, q2; for (int i = 1, x; i <= n; ++i) { cin >> x; q1.pb(x); qw.insert(x); } deque <int> cur; vector <string> ans; while (!q1.empty()) { // deque <int> out = q1; // while (!out.empty()) // { // cout << out.front() << ' '; // out.pop_front(); // } // cout << nl; int need = *qw.rbegin(); while (!q1.empty() && q1.front() != need) { string s = "UZMI L L"; ans.pb(s); s = "STAVI L D"; ans.pb(s); cur.push_front(q1.front()); q1.pop_front(); } string s = "UZMI D L"; ans.pb(s); q1.pop_front(); while (!cur.empty()) { s = "UZMI L D"; ans.pb(s); s = "STAVI L L"; ans.pb(s); q1.push_front(cur.front()); cur.pop_front(); } s = "STAVI D D"; ans.pb(s); qw.erase(qw.find(need)); } cout << sz(ans) << nl; for (string x : ans) cout << x << nl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); int ttt = 1; // cin >> ttt; for (int test = 1; test <= ttt; ++test) { // cout << "Case " << test << ":" << ' '; ma1n(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...