# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
639829 | piOOE | Scales (IOI15_scales) | C++17 | 1 ms | 340 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>
#include "scales.h"
using namespace std;
void init(int T) {
}
constexpr int n = 6;
void ord(int a[]) {
int x = getHeaviest(a[0], a[1], a[2]);
int y = getMedian(a[0], a[1], a[2]);
int z = a[0] + a[1] + a[2] - x - y;
a[0] = x, a[1] = y, a[2] = z;
}
int p[n], a[3], b[3], ans[3];
void orderCoins() {
iota(a, a + 3, 1), iota(b, b + 3, 4);
ord(a), ord(b);
for (int i = 0; i < 3; ++i) {
ans[i] = getNextLightest(a[0], a[1], a[2], b[i]);
}
if (ans[0] == ans[1] && ans[1] == ans[2] && ans[0] == a[2]) {
//either all bigger or all smaller
bool smaller = getLightest(a[0], a[1], b[0]) == b[0];
if (smaller) {
for (int i = 0; i < 3; ++i) {
p[i] = a[i];
p[i + 3] = b[i];
}
} else {
for (int i = 0; i < 3; ++i) {
p[i] = b[i];
p[i + 3] = a[i];
}
}
reverse(p, p + n);
answer(p);
} else {
int pntB = 0, pnt = 0;
for (int i = 0; i < 3; ++i) {
if (ans[i] == a[2]) {
p[pnt++] = b[i];
++pntB;
} else {
break;
}
}
for (int i = 0; i < 3; ++i) {
p[pnt++] = a[i];
while (pntB < 3 && ans[pntB] == a[i]){
p[pnt++] = b[pntB++];
}
}
reverse(p, p + n);
answer(p);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |