Submission #800674

#TimeUsernameProblemLanguageResultExecution timeMemory
800674happypotatoScales (IOI15_scales)C++17
0 / 100
1 ms212 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define ff first #define ss second #define pb push_back void init(int T) { } /* getHeaviest() getLightest() getMedian() getNextLightest() */ vector<pair<int, vector<int>>> clues; // {type, {answer, [query elements]}} vector<int> perm = {0, 1, 2, 3, 4, 5, 6}; vector<vector<int>> FindAllPossible() { sort(perm.begin(), perm.end()); vector<vector<int>> res = {}; do { bool valid = true; for (pair<int, vector<int>> &cur : clues) { // cerr << "CLUE " << cur.ff << ' '; // for (int &x : cur.ss) cerr << x << ' '; cerr << endl; if (cur.ff == 1) { for (int i = 1; i <= 3; i++) { if (cur.ss[0] == cur.ss[i]) continue; valid &= (perm[cur.ss[0]] > perm[cur.ss[i]]); } } if (cur.ff == 2) { for (int i = 1; i <= 3; i++) { if (cur.ss[0] == cur.ss[i]) continue; valid &= (perm[cur.ss[0]] < perm[cur.ss[i]]); } } if (cur.ff == 3) { int cnt = 0; for (int i = 1; i <= 3; i++) { if (cur.ss[0] == cur.ss[i]) continue; cnt += (perm[cur.ss[0]] < perm[cur.ss[i]]); } valid &= (cnt == 1); } if (cur.ff == 4) { bool allsmaller = true; for (int i = 1; i <= 3; i++) { allsmaller &= (perm[cur.ss[i]] < perm[cur.ss[4]]); } if (allsmaller) { for (int i = 1; i <= 3; i++) { if (cur.ss[0] == cur.ss[i]) continue; valid &= (perm[cur.ss[i]] < perm[cur.ss[0]]); } } else { valid &= (perm[cur.ss[0]] > perm[cur.ss[4]]); for (int i = 1; i <= 3; i++) { if (cur.ss[0] == cur.ss[i]) continue; valid &= (perm[cur.ss[i]] < perm[cur.ss[4]] || perm[cur.ss[i]] > perm[cur.ss[0]]); } } } if (!valid) break; } if (valid) { // cerr << "FOUND "; // for (int &x : perm) cerr << x << ' '; // cerr << endl; res.pb(perm); } } while (next_permutation(perm.begin() + 1, perm.end())); if (res.empty()) { throw runtime_error("cannot find correct permutation?"); } return res; } void Answer(vector<int> v) { int ans[6]; for (int i = 1; i <= 6; i++) ans[v[i] - 1] = i; answer(ans); } int Heaviest(int a, int b, int c = 0) { if (c == 0) c = (min(a, b) != 1 ? 1 : max(a, b) != 2 ? 2 : 3); int res = getHeaviest(a, b, c); clues.pb({1, {res, a, b, c}}); return res; } int Lightest(int a, int b, int c = 0) { if (c == 0) c = (min(a, b) != 1 ? 1 : max(a, b) != 2 ? 2 : 3); int res = getLightest(a, b, c); clues.pb({2, {res, a, b, c}}); return res; } int Median(int a, int b, int c) { int res = getMedian(a, b, c); clues.pb({3, {res, a, b, c}}); return res; } int NextLightest(int a, int b, int c, int d) { int res = getNextLightest(a, b, c, d); clues.pb({4, {res, a, b, c, d}}); return res; } /* getHeaviest() getLightest() getMedian() getNextLightest() */ void orderCoins() { clues.clear(); int mini = Lightest(Lightest(1, 2, 3), Lightest(4, 5, 6)); int maxi = Heaviest(Heaviest(1, 2, 3), Heaviest(4, 5, 6)); // can opt 1 query vector<int> rem1; for (int i = 1; i <= 6; i++) { if (i != mini && i != maxi) rem1.pb(i); } int res1 = Lightest(rem1[0], rem1[1], rem1[2]); vector<int> rem2; for (int &x : rem1) { if (x != res1) rem2.pb(x); } int res2 = Lightest(rem2[0], rem2[1], rem2[2]); if (res2 == rem1[3]) { Lightest(maxi, rem2[0], rem2[1]); } Answer(FindAllPossible().front()); } /* 15 edges to consider (know all -> must can sort) */

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...