Submission #520330

#TimeUsernameProblemLanguageResultExecution timeMemory
520330silverfishScales (IOI15_scales)C++17
0 / 100
2 ms332 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; #define pb push_back const int INF = 1000; int ind[6]; map<int, int[6]> ans; int nextl(int A, int B, int C, int D) { int allLess = 1; A--; B--; C--; D--; if (ind[A] > ind[D] || ind[B] > ind[D] || ind[C] > ind[D]) allLess = 0; if (allLess == 1) { if (ind[A] < ind[B] && ind[A] < ind[C]) return A + 1; if (ind[B] < ind[A] && ind[B] < ind[C]) return B + 1; return C + 1; } if (ind[A] > ind[D]) { if ((ind[A] < ind[B] || ind[B] < ind[D]) && (ind[A] < ind[C] || ind[C] < ind[D])) return A + 1; } if (ind[B] > ind[D]) { if ((ind[B] < ind[A] || ind[A] < ind[D]) && (ind[B] < ind[C] || ind[C] < ind[D])) return B + 1; } return C + 1; } int mid(int A, int B, int C) { A--; B--; C--; if (ind[B] < ind[A] && ind[A] < ind[C]) return A + 1; if (ind[C] < ind[A] && ind[A] < ind[B]) return A + 1; if (ind[A] < ind[B] && ind[B] < ind[C]) return B + 1; if (ind[C] < ind[B] && ind[B] < ind[A]) return B + 1; return C + 1; } int heavy(int A, int B, int C) { A--; B--; C--; if (ind[A] > ind[B] && ind[A] > ind[C]) return A + 1; if (ind[B] > ind[A] && ind[B] > ind[C]) return B + 1; return C + 1; } int light(int A, int B, int C) { A--; B--; C--; if (ind[A] < ind[B] && ind[A] < ind[C]) return A + 1; if (ind[B] < ind[A] && ind[B] < ind[C]) return B + 1; return C + 1; } void init(int T) { vector<int> p = {1, 2, 3, 4, 5, 6}; map<int,int> cnt; do{ for(int i = 0; i < 6; ++i) ind[p[i]-1] = i; vector<int> q; q.pb(nextl(6,5,1,2)); q.pb(nextl(5,4,6,1)); q.pb(nextl(5,6,2,4)); q.pb(nextl(6,2,1,3)); q.pb(nextl(5,6,4,3)); q.pb(mid(1,2,3)); q.pb(mid(4,5,6)); q.pb(mid(3,4,5)); reverse(q.begin(), q.end()); int mul = 1, cur = 0; for(int x : q){ cur += mul*x; mul *= 10; } int v = 0; mul = 1; for(int i = 0; i < 6; ++i){ ans[cur][i] = p[i]; } ++cnt[cur]; }while(next_permutation(p.begin(), p.end())); int mx = 0, mxpos; for(auto [x,c] : cnt){ if(c > mx){ mx = c; mxpos = x; } } // cout << mx << ' ' << mxpos << '\n'; return; } void orderCoins() { vector<int> q; q.pb(getNextLightest(6,5,1,2)); q.pb(getNextLightest(5,4,6,1)); q.pb(getNextLightest(5,6,2,4)); q.pb(getNextLightest(6,2,1,3)); q.pb(getNextLightest(5,6,4,3)); q.pb(getMedian(1,2,3)); q.pb(getMedian(4,5,6)); q.pb(getMedian(3,4,5)); reverse(q.begin(), q.end()); int mul = 1, cur = 0; for(int x : q){ cur += mul*x; mul *= 10; } //cout << cur << '\n'; for(int i = 0; i < 6; ++i) cout << ans[cur][i] << ' '; cout << '\n'; answer(ans[cur]); return; }

Compilation message (stderr)

scales.cpp: In function 'void init(int)':
scales.cpp:104:7: warning: unused variable 'v' [-Wunused-variable]
  104 |   int v = 0;
      |       ^
scales.cpp:112:14: warning: variable 'mxpos' set but not used [-Wunused-but-set-variable]
  112 |  int mx = 0, mxpos;
      |              ^~~~~
scales.cpp:82:15: warning: unused parameter 'T' [-Wunused-parameter]
   82 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...