제출 #374958

#제출 시각아이디문제언어결과실행 시간메모리
374958idk321저울 (IOI15_scales)C++11
71.43 / 100
1 ms492 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; void init(int T) { /* ... */ } void orderCoins() { /* ... */ int a = getLightest(1, 2, 3); int b = getLightest(4, 5, 6); set<int> l = {1, 2, 3}; set<int> r = {4, 5, 6}; l.erase(a); r.erase(b); vector<int> res; int c = getLightest(*l.begin(), a, b); res.push_back(c); if (c == a) { swap(a, b); swap(l, r); } auto it2 = r.begin(); it2++; int x = getLightest(a, *r.begin(), *it2); int oldX = x; res.push_back(x); if (x == a) { set<int> other; for (int i : l) other.insert(i); for (int i : r) other.insert(i); auto it3 = other.begin(); vector<int> v(3); v[0] = *it3; it3++; v[1] = *it3; it3++; v[2] = *it3; int x = getLightest(v[0], v[1], v[2]); other.erase(x); int y = *other.begin(); other.erase(y); int z = *other.begin(); other.erase(z); int d = *other.begin(); int t1 = getNextLightest(oldX, x, y, d); if (t1 == x) { res.push_back(d); res.push_back(x); int t2 = getMedian(oldX, y, z); if (t2 == y) { res.push_back(y); res.push_back(z); } else { res.push_back(z); res.push_back(y); } } else { if (t1 == oldX) swap(d, y); res.push_back(x); int t2 = getMedian(y, z, d); if (t2 == z) { res.push_back(d); res.push_back(z); res.push_back(y); } else if (t2 == d) { res.push_back(z); res.push_back(d); res.push_back(y); } else { res.push_back(d); res.push_back(y); res.push_back(z); } } } else { r.erase(x); set<int> other; for (int i : l) other.insert(i); for (int i : r) other.insert(i); auto it3 = other.begin(); vector<int> v(3); for (int i = 0; i < 3; i++) { v[i] = *it3; it3++; } int x = getLightest(v[0], v[1], v[2]); int y = getMedian(v[0], v[1], v[2]); other.erase(x); other.erase(y); int last = *other.begin(); if (x == *r.begin()) { int z = getLightest(x, a, y); if (z == a) { res.push_back(a); res.push_back(x); res.push_back(y); res.push_back(last); } else { res.push_back(x); res.push_back(a); res.push_back(y); res.push_back(last); } } else { res.push_back(a); res.push_back(x); res.push_back(y); res.push_back(last); } } int W[] = {1, 2, 3, 4, 5, 6}; for (int i = 0; i < 6; i++) W[i] = res[i]; answer(W); } /* 1 1 3 2 5 4 6 */

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

scales.cpp: In function 'void init(int)':
scales.cpp:7:15: warning: unused parameter 'T' [-Wunused-parameter]
    7 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:47:13: warning: declaration of 'x' shadows a previous local [-Wshadow]
   47 |         int x = getLightest(v[0], v[1], v[2]);
      |             ^
scales.cpp:32:9: note: shadowed declaration is here
   32 |     int x = getLightest(a, *r.begin(), *it2);
      |         ^
scales.cpp:105:13: warning: declaration of 'x' shadows a previous local [-Wshadow]
  105 |         int x = getLightest(v[0], v[1], v[2]);
      |             ^
scales.cpp:32:9: note: shadowed declaration is here
   32 |     int x = getLightest(a, *r.begin(), *it2);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...