# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
301944 | square1001 | Scales (IOI15_scales) | C++14 | 1 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "scales.h"
#include <vector>
using namespace std;
void init(int T) {
/* ... */
}
void orderCoins() {
int LA = getHeaviest(1, 2, 3);
int LB = getHeaviest(4, 5, 6);
int LC = getHeaviest(LA, LB, LA == 1 ? 2 : 1);
vector<int> rem;
if(LC == LA) {
rem.push_back(LA == 1 ? 2 : (LA == 2 ? 3 : 1));
rem.push_back(LA == 1 ? 3 : (LA == 2 ? 1 : 2));
rem.push_back(LB == 4 ? 5 : (LB == 5 ? 6 : 4));
rem.push_back(LB == 4 ? 6 : (LB == 5 ? 4 : 5));
rem.push_back(LB == 4 ? 4 : (LB == 5 ? 5 : 6));
}
else {
rem.push_back(LB == 4 ? 5 : (LB == 5 ? 6 : 4));
rem.push_back(LB == 4 ? 6 : (LB == 5 ? 4 : 5));
rem.push_back(LA == 1 ? 2 : (LA == 2 ? 3 : 1));
rem.push_back(LA == 1 ? 3 : (LA == 2 ? 1 : 2));
rem.push_back(LA == 1 ? 1 : (LA == 2 ? 2 : 3));
}
int g1 = getLightest(rem[0], rem[1], rem[2]);
int g2 = getMedian(rem[0], rem[1], rem[2]);
int g3 = getHeaviest(rem[0], rem[1], rem[2]);
int t1 = getLightest(rem[3], g2, LC);
int t2 = getLightest(rem[4], g2, LC);
int u1 = (t1 == g2 ? getLightest(rem[3], g3, LC) : getLightest(rem[3], g1, LC));
int u2 = (t2 == g2 ? getLightest(rem[4], g3, LC) : getLightest(rem[4], g1, LC));
int r1 = (t1 == g2 ? (u1 == g3 ? 3 : 2) : (u1 == g1 ? 1 : 0));
int r2 = (t2 == g2 ? (u2 == g3 ? 3 : 2) : (u2 == g1 ? 1 : 0));
vector<int> p5 = { g1, g2, g3 };
if(r1 > r2) {
p5.insert(p5.begin() + r1, rem[3]);
p5.insert(p5.begin() + r2, rem[4]);
}
else {
p5.insert(p5.begin() + r2, rem[4]);
p5.insert(p5.begin() + r1, rem[3]);
}
int W[6] = {p5[0], p5[1], p5[2], p5[3], p5[4], LC};
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |