Submission #707443

#TimeUsernameProblemLanguageResultExecution timeMemory
707443Chal1shkanKnjige (COCI20_knjige)C++14
0 / 50
3 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; queue <int> q1, q2; for (int i = 1, x; i <= n; ++i) { cin >> x; q1.push(x); qw.insert(x); } queue <int> cur; vector <string> ans; while (!q1.empty()) { 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(q1.front()); q1.pop(); } string s = "UZMI D L"; ans.pb(s); q1.pop(); while (!cur.empty()) { s = "UZMI L D"; ans.pb(s); s = "STAVI L L"; ans.pb(s); q1.push(cur.front()); cur.pop(); } 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...