# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
427878 | timmyfeng | Scales (IOI15_scales) | C++17 | 0 ms | 0 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 <bits/stdc++.h>
using namespace std;
#include "scales.h"
int perm[6];
void rotate(int a, int b) {
rotate(perm + a, perm + b, perm + b - 1);
}
void init(int t) {
}
void orderCoins() {
perm[0] = getLightest(1, 2, 3);
perm[1] = 1 + (perm[0] == 1);
perm[2] = 4;
perm[3] = 3 - (perm[0] == 3);
perm[4] = 5;
perm[5] = 6;
int mid = getMedian(perm[0], perm[1], 4);
if (mid == perm[0]) {
rotate(0, 3);
} else if (mid == 4) {
rotate(1, 3);
}
int nxt = getNextLightest(perm[0], perm[1], perm[2], perm[3]);
if (nxt == perm[1]) {
rotate(1, 4);
} else if (nxt == perm[2]) {
rotate(1, 3);
}
mid = getMedian(perm[1], perm[2], 5);
if (mid == perm[1]) {
if (getLightest(perm[0], perm[1], 5) == 5) {
rotate(0, 5);
} else {
rotate(1, 5);
}
} else if (mid == 5) {
rotate(2, 5);
} else if (getHeaviest(perm[3], perm[4], 5) == perm[4]) {
rotate(3, 5);
}
mid = getMedian(perm[1], perm[3], 6);
if (mid == perm[1]) {
if (getLightest(perm[0], perm[1], 6) == 6) {
rotate(0, 6);
} else {
rotate(1, 6);
}
} else if (mid == 6) {
if (getLightest(perm[2], perm[3], 6) == 6) {
rotate(2, 6);
} else {
rotate(3, 6);
}
} else if (getHeaviest(perm[4], perm[5], 6) == perm[5]) {
rotate(4, 6);
}
return perm;
}