제출 #832346

#제출 시각아이디문제언어결과실행 시간메모리
832346Valaki2저울 (IOI15_scales)C++14
71.43 / 100
1 ms296 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second void init(int T) { /* ... */ } int res[6]; void rem(vector<int> &v, int x) { set<int> s; for(int y : v) { if(y != x) { s.insert(y); } } v.clear(); for(int y : s) { v.pb(y); } } void solve_for_4(vector<int> &order, vector<int> v) { int a = v[0], b = v[1], c = v[2], d = v[3]; int mini = getLightest(a, b, c); if(mini == b) { swap(a, b); } if(mini == c) { swap(a, c); } // here, a is the 'mini' int maxi = getHeaviest(b, c, d); if(maxi == d) { int mid = getLightest(b, c, d); if(mid == c) { swap(b, c); } order.pb(a); order.pb(b); order.pb(c); order.pb(d); return; } if(maxi == b) { swap(b, c); } // here, the biggest element is c, and we know that a < b /* XABCD A=<<? B*=<? C**=? D***= */ // a < b < c int nxt = getNextLightest(a, b, c, d); vector<int> w; if(nxt == a) { w = {d, a, b, c}; } if(nxt == b) { w = {a, d, b, c}; } if(nxt == c) { w = {a, b, d, c}; } for(int x : w) { order.pb(x); } } void orderCoins() { /* ... */ vector<int> order; int x = getLightest(1, 2, 3), y = getLightest(4, 5, 6); int z = (x == 1 ? 2 : 1); int w = getLightest(x, y, z); order.pb(w); int u = -1; if(x == w) { set<int> s; s.insert(1); s.insert(2); s.insert(3); s.erase(w); u = getLightest(y, *s.begin(), *s.rbegin()); } else { set<int> s; s.insert(4); s.insert(5); s.insert(6); s.erase(w); u = getLightest(x, *s.begin(), *s.rbegin()); } order.pb(u); set<int> s; for(int i = 1; i <= 6; i++) { s.insert(i); } s.erase(w); s.erase(u); vector<int> v; v.clear(); for(int x : s) { v.pb(x); } solve_for_4(order, v); for(int i = 0; i < 6; i++) { res[i] = order[i]; } answer(res); }

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

scales.cpp: In function 'void init(int)':
scales.cpp:12:15: warning: unused parameter 'T' [-Wunused-parameter]
   12 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:113:13: warning: declaration of 'x' shadows a previous local [-Wshadow]
  113 |     for(int x : s) {
      |             ^
scales.cpp:84:9: note: shadowed declaration is here
   84 |     int x = getLightest(1, 2, 3), y = getLightest(4, 5, 6);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...