# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1061495 | anango | 저울 (IOI15_scales) | C++17 | 1 ms | 392 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |