Submission #1177641

#TimeUsernameProblemLanguageResultExecution timeMemory
1177641BlockOGScales (IOI15_scales)C++20
45.80 / 100
0 ms328 KiB
#include "scales.h" #include <bits/stdc++.h> // meeeow mrrow :3c // steam on free !vivid/stasis play #define fo(i, a, b) for (auto i = (a); i < (b); i++) #define of(i, a, b) for (auto i = (b); i-- > (a);) #define pb push_back #define pob pop_back using namespace std; void ans(vector<int> &w) { for (int &v : w) v++; answer(w.data()); } int gl(int a, int b, int c) { return getLightest(a + 1, b + 1, c + 1) - 1; } int gh(int a, int b, int c) { return getHeaviest(a + 1, b + 1, c + 1) - 1; } int gm(int a, int b, int c) { return getMedian(a + 1, b + 1, c + 1) - 1; } int nl(int a, int b, int c, int d) { return getNextLightest(a + 1, b + 1, c + 1, d + 1) - 1; } int gi(int v, vector<int> &w) { fo(i, 0, w.size()) if (w[i] == v) return i; return -1; } void init(int T) {} void orderCoins() { vector<int> w = {0, 1, 2}; vector<vector<int>> w2(4); swap(w[0], w[gi(gl(0, 1, 2), w)]); swap(w[2], w[gi(gh(0, 1, 2), w)]); fo(i, 3, 6) { w2[gi(nl(w[0], w[1], w[2], i), w)].pb(i); } if (w2[0].size() == 1) { if (gl(w2[0][0], w[0], w[1]) != w2[0][0]) swap(w2[0], w2[3]); } else if (w2[0].size() == 2) { int i = gi(gl(w2[0][0], w2[0][1], 0), w2[0]); if (i == -1) { swap(w2[0], w2[3]); swap(w2[3][1], w2[3][gi(gh(w2[3][0], w2[3][1], w[0]), w2[3])]); } else { swap(w2[0][0], w2[0][i]); if (gh(w2[0][0], w2[0][1], 0) != 0) { w2[3].pb(w2[0][1]); w2[0].pob(); } } } else if (w2[0].size() == 3) { swap(w2[0][0], w2[0][gi(gl(3, 4, 5), w2[0])]); swap(w2[0][2], w2[0][gi(gh(3, 4, 5), w2[0])]); int m = gm(w2[0][0], w2[0][2], 0); if (m == w2[0][0]) { swap(w2[0], w2[3]); } else if (m == 0) { w2[3].pb(w2[0][2]); w2[0].pob(); if (gm(w2[0][0], w2[0][1], 0) == 0) { w2[3].pb(w2[0][1]); w2[0].pob(); swap(w2[3][0], w2[3][1]); } } } fo(i, 1, 3) { if (w2[i].size() == 2) { swap(w2[i][0], w2[i][gi(gl(w2[i][0], w2[i][1], w[i]), w2[i])]); } else if (w2[i].size() == 3) { swap(w2[i][0], w2[i][gi(gl(3, 4, 5), w2[i])]); swap(w2[i][2], w2[i][gi(gh(3, 4, 5), w2[i])]); } } vector<int> res; fo(i, 0, 4) { for (int j : w2[i]) res.pb(j); if (i < 3) res.pb(w[i]); } ans(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...