Submission #378406

#TimeUsernameProblemLanguageResultExecution timeMemory
378406AraragiKnjige (COCI20_knjige)C++17
50 / 50
9 ms1752 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("00") typedef long long ll; typedef long double ld; typedef unsigned long long ull; typedef pair<int, int> pii; ll time() {return chrono::system_clock().now().time_since_epoch().count();} mt19937 rnd(time()); const int inf = 1e9; const ll inf64 = 1e18; #define ft first #define fin(x) ifstream cin("x.in"); #define fout(x) ofstream cout("x.out"); #define sd second #define pb push_back #define sz(x) (int)x.size() int hand[2]; vector<int> a[2]; vector<string> cmd; vector<int> num; bool cmp(int& x, int& y) {return (a[0][x] < a[0][y]);} void take(int fst, int scd) { cmd.pb((string)"UZMI " + (fst ? "D" : "L") + " " + (scd ? "D" : "L")); hand[fst] = a[scd].back(); a[scd].pop_back(); } void put(int fst, int scd) { cmd.pb((string)"STAVI " + (fst ? "D" : "L") + " " + (scd ? "D" : "L")); a[scd].pb(hand[fst]); hand[fst] = -1; } void nande(int where) {cerr << "called debug procedure...\n"; for (auto it : a[where]) cerr << it << " "; cerr << '\n'; cerr << "ended'\n";} int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); system("color 2"); int n; cin >> n; a[0].resize(n); num.resize(n); for (auto& it : a[0]) cin >> it; if (is_sorted(a[0].begin(), a[0].end())) { cout << "0"; return 0; } iota(num.begin(), num.end(), 0); sort(num.begin(), num.end(), cmp); for (int i = 0; i < n; i++) a[0][num[i]] = i + 1; reverse(a[0].begin(), a[0].end()); // 0 - LEFT, 1 - DANTE //int cnt = 0; for (int i = 0; i < n; i++) { //nande(0); while (a[0].back() != i + 1) { take(0, 0); put(0, 1); // cnt++; } take(1, 0); //nande(0); //nande(1); while ((i > 0 ? a[1].back() != i : !a[1].empty())) { take(0, 1); put(0, 0); } //nande(0); //nande(1); put(1, 0); //nande(0); //nande(1); while (!a[1].empty()) { take(0, 1); put(0, 0); } //nande(0); //nande(1); } cout << sz(cmd) << '\n'; for (auto it : cmd) cout << it << '\n'; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:43:11: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
   43 |     system("color 2");
      |     ~~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...