제출 #1039121

#제출 시각아이디문제언어결과실행 시간메모리
1039121c2zi6저울 (IOI15_scales)C++14
0 / 100
1 ms604 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "scales.h" void init(int T) { } void answer(VI ans); void orderCoins() { auto restf = [&](VI vec, int lim = 6){ VI ret; replr(i, 1, lim) { for (int x : vec) if (i == x) goto dontadd; ret.pb(i); dontadd:; } return ret; }; VI rel; /* relative order of 1, 2, 3, 4 */ int mn = getLightest(1, 2, 3); VI rest = restf({mn}, 3); int nxt = getNextLightest(rest[0], rest[1], 4, mn); if (nxt == 4) { if (getHeaviest(rest[0], rest[1], mn) == rest[0]) { rel = VI{mn, 4, rest[1], rest[0]}; } else { rel = VI{mn, 4, rest[0], rest[1]}; } } else { int rest = restf({mn, nxt}, 3)[0]; int med = getMedian(mn, rest, 4); if (med == mn) { rel = VI{4, mn, nxt, rest}; } else if (med == rest) { rel = VI{mn, nxt, rest, 4}; } else if (med == 4) { rel = VI{mn, nxt, 4, rest}; } } int med = getMedian(rel[0], 5, 6); // minchev hmi ogtagorcac e 4 gorcoxutyun if (med == 5) { int med = getMedian(rel[2], 5, 6); if (med == rel[2]) { bool a = (getLightest(rel[1], 5, 6) == rel[1]); bool b = (getHeaviest(rel[3], 5, 6) != rel[1]); VI ans; ans.pb(rel[0]); if (a) { ans.pb(rel[1]); ans.pb(5); } else { ans.pb(5); ans.pb(rel[1]); } ans.pb(rel[2]); if (b) { ans.pb(rel[3]); ans.pb(6); } else { ans.pb(6); ans.pb(rel[3]); } answer(ans); return; } else if (med == 5) { int med = getMedian(rel[3], 5, 6); if (med == rel[3]) { answer({rel[0], rel[1], rel[2], 5, rel[3], 6}); return; } else if (med == 5) { answer({rel[0], rel[1], rel[2], rel[3], 5, 6}); return; } else if (med == 6) { answer({rel[0], rel[1], rel[2], 5, 6, rel[3]}); return; } } } else if (med == 6) { int med = getMedian(rel[2], 6, 5); if (med == rel[2]) { bool a = (getLightest(rel[1], 6, 5) == rel[1]); bool b = (getHeaviest(rel[3], 6, 5) != rel[1]); VI ans; ans.pb(rel[0]); if (a) { ans.pb(rel[1]); ans.pb(6); } else { ans.pb(6); ans.pb(rel[1]); } ans.pb(rel[2]); if (b) { ans.pb(rel[3]); ans.pb(5); } else { ans.pb(5); ans.pb(rel[3]); } answer(ans); return; } else if (med == 6) { int med = getMedian(rel[3], 6, 5); if (med == rel[3]) { answer({rel[0], rel[1], rel[2], 6, rel[3], 5}); return; } else if (med == 6) { answer({rel[0], rel[1], rel[2], rel[3], 6, 5}); return; } else if (med == 5) { answer({rel[0], rel[1], rel[2], 6, 5, rel[3]}); return; } } } else { int med = getMedian(rel[0], rel[1], 5); if (med == 5) { answer({6, rel[0], 5, rel[1], rel[2], rel[3]}); return; } else if (med == rel[1]) { int med = getMedian(rel[2], rel[3], 5); if (med == 5) { answer({6, rel[0], rel[1], rel[2], 5, rel[3]}); return; } else if (med == rel[2]) { answer({6, rel[0], rel[1], 5, rel[2], rel[3]}); return; } else if (med == rel[3]) { answer({6, rel[0], rel[1], rel[2], rel[3], 5}); return; } } else if (med == rel[0]) { if (getLightest(rel[1], rel[2], 6) == 6) { answer({5, rel[0], 6, rel[1], rel[2], rel[3]}); return; } else { int med = getMedian(rel[2], rel[3], 6); if (med == rel[3]) { answer({5, rel[0], rel[1], rel[2], rel[3], 6}); return; } else if (med == 6) { answer({5, rel[0], rel[1], rel[2], 6, rel[3]}); return; } else if (med == rel[2]) { answer({5, rel[0], rel[1], 6, rel[2], rel[3]}); return; } } } } VI ans(6); answer(ans); } void answer(VI ans) { int w[6]; rep(i, 6) w[i] = ans[i]; answer(w); }

컴파일 시 표준 에러 (stderr) 메시지

scales.cpp: In function 'void init(int)':
scales.cpp:34:15: warning: unused parameter 'T' [-Wunused-parameter]
   34 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:61:13: warning: declaration of 'rest' shadows a previous local [-Wshadow]
   61 |         int rest = restf({mn, nxt}, 3)[0];
      |             ^~~~
scales.cpp:52:8: note: shadowed declaration is here
   52 |     VI rest = restf({mn}, 3);
      |        ^~~~
scales.cpp:75:13: warning: declaration of 'med' shadows a previous local [-Wshadow]
   75 |         int med = getMedian(rel[2], 5, 6);
      |             ^~~
scales.cpp:72:9: note: shadowed declaration is here
   72 |     int med = getMedian(rel[0], 5, 6);
      |         ^~~
scales.cpp:99:17: warning: declaration of 'med' shadows a previous local [-Wshadow]
   99 |             int med = getMedian(rel[3], 5, 6);
      |                 ^~~
scales.cpp:75:13: note: shadowed declaration is here
   75 |         int med = getMedian(rel[2], 5, 6);
      |             ^~~
scales.cpp:112:13: warning: declaration of 'med' shadows a previous local [-Wshadow]
  112 |         int med = getMedian(rel[2], 6, 5);
      |             ^~~
scales.cpp:72:9: note: shadowed declaration is here
   72 |     int med = getMedian(rel[0], 5, 6);
      |         ^~~
scales.cpp:136:17: warning: declaration of 'med' shadows a previous local [-Wshadow]
  136 |             int med = getMedian(rel[3], 6, 5);
      |                 ^~~
scales.cpp:112:13: note: shadowed declaration is here
  112 |         int med = getMedian(rel[2], 6, 5);
      |             ^~~
scales.cpp:149:13: warning: declaration of 'med' shadows a previous local [-Wshadow]
  149 |         int med = getMedian(rel[0], rel[1], 5);
      |             ^~~
scales.cpp:72:9: note: shadowed declaration is here
   72 |     int med = getMedian(rel[0], 5, 6);
      |         ^~~
scales.cpp:154:17: warning: declaration of 'med' shadows a previous local [-Wshadow]
  154 |             int med = getMedian(rel[2], rel[3], 5);
      |                 ^~~
scales.cpp:149:13: note: shadowed declaration is here
  149 |         int med = getMedian(rel[0], rel[1], 5);
      |             ^~~
scales.cpp:170:21: warning: declaration of 'med' shadows a previous local [-Wshadow]
  170 |                 int med = getMedian(rel[2], rel[3], 6);
      |                     ^~~
scales.cpp:149:13: note: shadowed declaration is here
  149 |         int med = getMedian(rel[0], rel[1], 5);
      |             ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...