Submission #835142

#TimeUsernameProblemLanguageResultExecution timeMemory
835142MadokaMagicaFanScales (IOI15_scales)C++14
55.73 / 100
1 ms304 KiB
#include "bits/stdc++.h" #include "scales.h" using namespace std; #define pb push_back #ifndef ONPC mt19937 rng(time(NULL)); #endif void init(int T) { } int cnt = 0; void order(vector<int> &a) { cnt += 2; int x = getLightest(a[0], a[1], a[2]); int y = getMedian(a[0], a[1], a[2]); a[2] = a[2] + a[1] + a[0] - x - y; a[0] = x; a[1] = y; } void add3(vector<int> &a, int x) { ++cnt; int u = getMedian(a[1], a[2], x); if (u == a[2]) { a.push_back(x); return; } if (u == x) { a.push_back(x); swap(a[2], a[3]); return; } u = getMedian(a[0], a[1], x); ++cnt; a.push_back(x); swap(a[2], a[3]); swap(a[1], a[2]); if (u == a[0]) swap(a[0], a[1]); } void add2(vector<int> &a, int x) { int u = getMedian(a[0], a[1], x); a.push_back(x); if (u == a[1]) return; swap(a[1], a[2]); if (u == x) return; swap(a[0], a[1]); } vector<int> cmp(vector<int> a, vector<int> b) { vector<int> res; int z = getNextLightest(a[0], a[1], a[2], b[1]); ++cnt; int p; if (z == a[0]) { ++cnt; z = getMedian(a[0], b[1], a[2]); if (z == a[0]) p = 0; else p = 4; } else if (z == a[1]) p = 1; else p = 2; if (p == 0) { res.pb(b[0]); res.pb(b[1]); add3(a, b[2]); for (auto x : a) res.pb(x); return res; } else if (p == 4) { add3(a, b[0]); for (auto x : a) res.pb(x); res.pb(b[1]); res.pb(b[2]); return res; } vector<int> u, v; if (p == 1) { u = {a[0], b[1]}; v = {a[1], a[2]}; } else { u = {a[0], a[1]}; v = {b[1], a[2]}; } add2(u, b[0]); add2(v,b[2]); for (auto x : v) u.pb(x); return u; } void orderCoins() { int ans[6]; vector<int> a(6); iota(a.begin(), a.end(), 1); #ifndef ONPC shuffle(a.begin(), a.end(), rng); #endif vector<int> c = a; vector<int> b; b.pb(c.back()); c.pop_back(); b.pb(c.back()); c.pop_back(); b.pb(c.back()); c.pop_back(); order(b); order(c); a = cmp(b, c); for (int i = 0; i < 6; ++i) ans[i] = a[i]; answer(ans); }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:10:15: warning: unused parameter 'T' [-Wunused-parameter]
   10 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...