제출 #550534

#제출 시각아이디문제언어결과실행 시간메모리
550534elazarkorenScales (IOI15_scales)C++17
71.43 / 100
1 ms212 KiB
#include <bits/stdc++.h> #include "scales.h" #define x first #define y second #define all(v) v.begin(), v.end() #define chkmin(a, b) a = min(a, b) #define chkmax(a, b) a = max(a, b) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vii; mt19937 rng(time(0)); void init(int T) { } map<vi, int> asksLight; int queryLight(int a, int b, int c) { vi v = {a, b, c}; sort(all(v)); if (asksLight.count(v)) return asksLight[v]; return asksLight[v] = getLightest(a, b, c); } map<vi, int> asksHeavy; int queryHeavy(int a, int b, int c) { vi v = {a, b, c}; sort(all(v)); if (asksHeavy.count(v)) return asksHeavy[v]; return asksHeavy[v] = getHeaviest(a, b, c); } map<vi, int> asksMed; int queryMed(int a, int b, int c) { vi v = {a, b, c}; sort(all(v)); if (asksMed.count(v)) return asksMed[v]; return asksMed[v] = getMedian(a, b, c); } map<vi, int> asksNext; int queryNext(int a, int b, int c, int d) { vi v = {a, b, c}; sort(all(v)); v.push_back(d); if (asksNext.count(v)) return asksNext[v]; return asksNext[v] = getNextLightest(a, b, c, d); } vi Sort4(vi v) { int x = queryLight(v[0], v[1], v[2]); if (x == v[1]) swap(v[0], v[1]); else if (x == v[2]) swap(v[0], v[2]); x = queryHeavy(v[1], v[2], v[3]); if (x == v[2]) swap(v[3], v[2]); else if (x == v[1]) { swap(v[1], v[2]); swap(v[3], v[2]); } x = queryMed(v[0], v[1], v[2]); vi ans; if (x == v[0]) { ans = {v[2], v[0], v[1], v[3]}; } else if (x == v[1]) { ans = {v[0], v[1], v[2], v[3]}; } else { ans = {v[0], v[2], v[1], v[3]}; } return ans; } vi Sort5(vi v) { shuffle(all(v), rng); int x = v.back(); v.pop_back(); v = Sort4(v); int y = queryMed(v[0], v[1], x); vi ans; if (y == v[0]) { ans = {x, v[0], v[1], v[2], v[3]}; } else if (y == x) { ans = {v[0], x, v[1], v[2], v[3]}; } else { y = queryMed(v[2], v[3], x); if (y == v[2]) { ans = {v[0], v[1], x, v[2], v[3]}; } else if (y == x) { ans = {v[0], v[1], v[2], x, v[3]}; } else { ans = {v[0], v[1], v[2], v[3], x}; } } return ans; } vi Sort6() { vi v = {1, 2, 3, 4, 5, 6}; shuffle(all(v), rng); int x = v.back(); v.pop_back(); v = Sort5(v); int y = queryNext(v[0], v[2], v[4], x); vi ans; if (y == v[2]) { y = queryMed(v[0], v[1], x); if (v[1] == y) { ans = {v[0], v[1], x, v[2], v[3], v[4]}; } else { ans = {v[0], x, v[1], v[2], v[3], v[4]}; } } else if (y == v[4]) { y = queryMed(v[2], v[3], x); if (x == y) { ans = {v[0], v[1], v[2], x, v[3], v[4]}; } else { ans = {v[0], v[1], v[2], v[3], x, v[4]}; } } else { y = queryMed(v[0], v[4], x); if (y == v[0]) { ans = {x, v[0], v[1], v[2], v[3], v[4]}; } else if (y == v[4]) { ans = {v[0], v[1], v[2], v[3], v[4], x}; } } return ans; } void orderCoins() { int w[] = {1, 2, 3, 4, 5, 6}; // shuffle(w, w + 6, rng); asksLight.clear(); asksHeavy.clear(); asksMed.clear(); asksNext.clear(); vi v = Sort6(); for (int i = 0; i < 6; i++) { w[i] = v[i]; } answer(w); } //1 //3 4 6 2 1 5 //1 //2 3 1 5 6 4

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

scales.cpp: In function 'void init(int)':
scales.cpp:17:15: warning: unused parameter 'T' [-Wunused-parameter]
   17 | void init(int T) {
      |           ~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...