Submission #287742

#TimeUsernameProblemLanguageResultExecution timeMemory
287742amoo_safar저울 (IOI15_scales)C++17
100 / 100
2 ms360 KiB
#include "scales.h" #include <bits/stdc++.h> #define all(x) x.begin(), x.end() using namespace std; struct Query { int type; int a, b, c, d; int res; Query (int _type, int _a, int _b, int _c, int _d, int _res){ type = _type; a = _a; b = _b; c = _c; d = _d; res = _res; } }; vector<Query> Asked; int AskMin(int a, int b, int c){ int res = getLightest(a, b, c); Query nw(0, a, b, c, -1, res); Asked.push_back(nw); return res; } int AskMax(int a, int b, int c){ int res = getHeaviest(a, b, c); Query nw(1, a, b, c, -1, res); Asked.push_back(nw); return res; } int AskMedian(int a, int b, int c){ int res = getMedian(a, b, c); Query nw(2, a, b, c, -1, res); Asked.push_back(nw); return res; } int AskNext(int a, int b, int c, int d){ int res = getNextLightest(a, b, c, d); Query nw(3, a, b, c, d, res); Asked.push_back(nw); return res; } int Next(int a, int b, int c, int d){ vector<int> Arr = {a, b, c}; sort(all(Arr)); auto it = lower_bound(all(Arr), d); if(it == Arr.end()) return Arr[0]; return *it; } void Solve(){ vector<int> per(7); int W[] = {-1, -1, -1, -1, -1, -1}; iota(per.begin(), per.end(), 0); int mn, mx, sm; do { bool flg = true; for(auto X : Asked){ mn = min({per[X.a], per[X.b], per[X.c]}); mx = max({per[X.a], per[X.b], per[X.c]}); sm = per[X.a] + per[X.b] + per[X.c]; if(X.type == 0) flg &= (per[X.res] == mn); if(X.type == 1) flg &= (per[X.res] == mx); if(X.type == 2) flg &= (per[X.res] == sm - mn - mx); if(X.type == 3) flg &= (per[X.res] == Next(per[X.a], per[X.b], per[X.c], per[X.d])); } if(!flg) continue; for(int i = 1; i <= 6; i++) W[per[i] - 1] = i; answer(W); return ; } while(next_permutation(per.begin() + 1, per.end())); assert(false); return ; } void init(int T) { assert(T != -1); return ; } void orderCoins(){ Asked.clear(); int W[] = {1, 2, 3, 4, 5, 6}; int S4[] = {0, 0, 0, 0}, p = 0; int res, A, B, C, D, E, F; int V[] = {1, 2, 3, 4, 5, 6}; res = AskMax(1, 2, 3); if(res == 2) swap(V[1], V[0]); if(res == 3) swap(V[2], V[0]); res = AskMedian(4, 5, 6); if(res == 5) swap(V[4], V[3]); if(res == 6) swap(V[5], V[3]); int tmp; tmp = AskNext(V[2], V[4], V[5], V[1]); // Next(V[2], V[4], V[5], V[1]); if(tmp == V[2]){ // 26 int a2 = 1, b2 = 4, c2 = 5; int tmp2 = AskMin(V[a2], V[b2], V[c2]); if(tmp2 == V[a2]){ // 8 int a3 = 3, b3 = 4, c3 = 5; int tmp3 = AskNext(V[a3], V[b3], V[c3], V[0]); if(tmp3 == V[a3]){ // 2 int a4 = 0, b4 = 4, c4 = 5; int tmp4 = AskMin(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[b3]){ // 3 int a4 = 0, b4 = 3, c4 = 4; int tmp4 = AskMax(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[c3]){ // 3 int a4 = 0, b4 = 4, c4 = 5; int tmp4 = AskMax(V[a4], V[b4], V[c4]); Solve(); return ; } } if(tmp2 == V[b2]){ // 9 int a3 = 1, b3 = 2, c3 = 3; int tmp3 = AskMedian(V[a3], V[b3], V[c3]); if(tmp3 == V[a3]){ // 3 int a4 = 0, b4 = 2, c4 = 5; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[b3]){ // 3 int a4 = 0, b4 = 3, c4 = 5; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[c3]){ // 3 int a4 = 0, b4 = 1, c4 = 5; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } } if(tmp2 == V[c2]){ // 9 int a3 = 1, b3 = 2, c3 = 3; int tmp3 = AskMedian(V[a3], V[b3], V[c3]); if(tmp3 == V[a3]){ // 3 int a4 = 0, b4 = 1, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[b3]){ // 3 int a4 = 0, b4 = 3, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[c3]){ // 3 int a4 = 0, b4 = 1, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } } } if(tmp == V[5]) swap(V[4], V[5]); if(tmp == V[4]){ // 27 int a2 = 2, b2 = 4, c2 = 5; int tmp2 = AskMin(V[a2], V[b2], V[c2]); if(tmp2 == V[a2]){ // 9 int a3 = 0, b3 = 4, c3 = 5; int tmp3 = AskMax(V[a3], V[b3], V[c3]); if(tmp3 == V[a3]){ // 3 int a4 = 1, b4 = 3, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[b3]){ // 3 int a4 = 0, b4 = 1, c4 = 3; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[c3]){ // 3 int a4 = 0, b4 = 3, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } } if(tmp2 == V[b2]){ // 9 int a3 = 1, b3 = 2, c3 = 3; int tmp3 = AskMax(V[a3], V[b3], V[c3]); if(tmp3 == V[a3]){ // 3 int a4 = 2, b4 = 3, c4 = 5; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[b3]){ // 3 int a4 = 0, b4 = 2, c4 = 5; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[c3]){ // 3 int a4 = 0, b4 = 3, c4 = 5; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } } if(tmp2 == V[c2]){ int a3 = 1, b3 = 2, c3 = 5; int tmp3 = AskNext(V[a3], V[b3], V[c3], V[3]); if(tmp3 == V[a3]){ // 3 int a4 = 0, b4 = 2, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[b3]){ // 3 int a4 = 0, b4 = 2, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } if(tmp3 == V[c3]){ // 3 int a4 = 0, b4 = 3, c4 = 4; int tmp4 = AskMedian(V[a4], V[b4], V[c4]); Solve(); return ; } } } return ; }

Compilation message (stderr)

scales.cpp: In function 'void orderCoins()':
scales.cpp:125:9: warning: unused variable 'tmp4' [-Wunused-variable]
  125 |     int tmp4 = AskMin(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:131:9: warning: unused variable 'tmp4' [-Wunused-variable]
  131 |     int tmp4 = AskMax(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:137:9: warning: unused variable 'tmp4' [-Wunused-variable]
  137 |     int tmp4 = AskMax(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:147:9: warning: unused variable 'tmp4' [-Wunused-variable]
  147 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:153:9: warning: unused variable 'tmp4' [-Wunused-variable]
  153 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:159:9: warning: unused variable 'tmp4' [-Wunused-variable]
  159 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:169:9: warning: unused variable 'tmp4' [-Wunused-variable]
  169 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:175:9: warning: unused variable 'tmp4' [-Wunused-variable]
  175 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:181:9: warning: unused variable 'tmp4' [-Wunused-variable]
  181 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:196:9: warning: unused variable 'tmp4' [-Wunused-variable]
  196 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:202:9: warning: unused variable 'tmp4' [-Wunused-variable]
  202 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:208:9: warning: unused variable 'tmp4' [-Wunused-variable]
  208 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:219:9: warning: unused variable 'tmp4' [-Wunused-variable]
  219 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:225:9: warning: unused variable 'tmp4' [-Wunused-variable]
  225 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:231:9: warning: unused variable 'tmp4' [-Wunused-variable]
  231 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:241:9: warning: unused variable 'tmp4' [-Wunused-variable]
  241 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:247:9: warning: unused variable 'tmp4' [-Wunused-variable]
  247 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:253:9: warning: unused variable 'tmp4' [-Wunused-variable]
  253 |     int tmp4 = AskMedian(V[a4], V[b4], V[c4]);
      |         ^~~~
scales.cpp:99:6: warning: unused variable 'W' [-Wunused-variable]
   99 |  int W[] = {1, 2, 3, 4, 5, 6};
      |      ^
scales.cpp:100:6: warning: unused variable 'S4' [-Wunused-variable]
  100 |  int S4[] = {0, 0, 0, 0}, p = 0;
      |      ^~
scales.cpp:100:27: warning: unused variable 'p' [-Wunused-variable]
  100 |  int S4[] = {0, 0, 0, 0}, p = 0;
      |                           ^
scales.cpp:101:11: warning: unused variable 'A' [-Wunused-variable]
  101 |  int res, A, B, C, D, E, F;
      |           ^
scales.cpp:101:14: warning: unused variable 'B' [-Wunused-variable]
  101 |  int res, A, B, C, D, E, F;
      |              ^
scales.cpp:101:17: warning: unused variable 'C' [-Wunused-variable]
  101 |  int res, A, B, C, D, E, F;
      |                 ^
scales.cpp:101:20: warning: unused variable 'D' [-Wunused-variable]
  101 |  int res, A, B, C, D, E, F;
      |                    ^
scales.cpp:101:23: warning: unused variable 'E' [-Wunused-variable]
  101 |  int res, A, B, C, D, E, F;
      |                       ^
scales.cpp:101:26: warning: unused variable 'F' [-Wunused-variable]
  101 |  int res, A, B, C, D, E, F;
      |                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...