제출 #1061495

#제출 시각아이디문제언어결과실행 시간메모리
1061495anango저울 (IOI15_scales)C++17
55.56 / 100
1 ms392 KiB
#include "scales.h" #include <bits/stdc++.h> using namespace std; int testcases; void init(int T) { /* ... */ testcases = T; } void orderCoins() { /* ... */ set<int> lev0; set<int> lev1; set<int> lev2; set<int> lev3; int a = 1; int b = 2; int c = 3; int d = 4; int e = 5; int f = 6; //get the heaviest 3, then the lightest 1, then use the level method with medians int h1 = getHeaviest(a,b,c); int h2 = getHeaviest(d,e,f); if (h1==a) swap(a,c); if (h1==b) swap(b,c); if (h2==d) swap(d,f); if (h2==e) swap(e,f); //so h1 is c and h2 is f if (h1==getHeaviest(a,c,f)) { swap(h1,h2); swap(c,f); swap(a,d); swap(b,e); } //cout << "doing " << a <<" " << b <<" " << c <<" " << d <<" " << e <<" " << f << endl; lev3={f}; //now f>c //possibilities are: def,bcf,acf,cdf,cef //basically, need to remove lightest of bcde int a1 = getLightest(c,d,e); if (a1==c) { //def lev2={d,e}; lev1={a,b,c}; } else if (a1==d) { //cef or bcf or acf //want heaviest of a,b,e lev2={getHeaviest(a,b,e),c}; lev1={a,b,c,d,e}; for (auto i:lev2) lev1.erase(i); } else if (a1==e) { //cdf or bcf or acf //want heaviest of a,b,d lev2={getHeaviest(a,b,d),c}; lev1={a,b,c,d,e}; for (auto i:lev2) lev1.erase(i); } //cout << "doing " << a <<" " << b <<" " << c <<" " << d <<" " << e <<" " << f << endl; a1 = *lev1.begin(); int b1 = *next(lev1.begin()); int c1 = *next(next(lev1.begin())); int r = getLightest(a1,b1,c1); lev1.erase(r); lev0.insert(r); /*cout << "LEVELS" << endl; for (auto i:lev0) { cout << i <<" "; } cout << endl; for (auto i:lev1) { cout << i <<" "; } cout << endl; for (auto i:lev2) { cout << i <<" "; } cout << endl; for (auto i:lev3) { cout << i <<" "; } cout << endl;*/ a = *lev0.begin(); b = *lev1.begin(); c = *lev1.rbegin(); d = *lev2.begin(); e = *lev2.rbegin(); f = *lev3.begin(); if (getMedian(b,c,d)==b) { swap(b,c); } if (getMedian(c,d,e)==e) { swap(d,e); } int W[6] = {a,b,c,d,e,f}; answer(W); }
#Verdict Execution timeMemoryGrader output
Fetching results...