# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528332 | Cyanmond | Scales (IOI15_scales) | C++17 | 1 ms | 204 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.
// clang-format off
#include "scales.h"
#include <bits/stdc++.h>
void init(int T) {
/* ... */
}
void orderCoins() {
std::array<int, 3> A, B;
{
const int x = getHeaviest(1, 2, 3);
const int y = getLightest(1, 2, 3);
int z = 0;
for (int i = 1; i <= 3; ++i) {
if (i != x and i != y) z = i;
}
A = {y, z, x};
}
{
const int x = getHeaviest(4, 5, 6);
const int y = getLightest(4, 5, 6);
int z = 0;
for (int i = 4; i <= 6; ++i) {
if (i != x and i != y) z = i;
}
B = {y, z, x};
}
std::vector<int> res(3);
for (int i = 0; i < 3; ++i) res[i] = A[i];
const int r2 = getNextLightest(A[0], A[1], A[2], B[1]);
if (r2 == A[0]) {
const bool h = getMedian(A[0], A[1], B[1]) == A[0];
if (h) {
res.insert(res.begin(), B[1]);
res.insert(res.begin(), B[0]);
int r3 = getNextLightest(A[0], A[1], A[2], B[2]);
if (r3 == A[0]) res.insert(getMedian(A[0], A[1], B[2]) == A[0] ? res.begin() + 2 : res.end(), B[2]);
else res.insert(std::find(res.begin(), res.end(), r3), B[2]);
} else {
res.insert(res.end(), B[1]);
res.insert(res.end(), B[2]);
int r1 = getNextLightest(A[0], A[1], A[2], B[0]);
if (r1 == A[0]) res.insert(getMedian(A[0], A[1], B[0]) == A[0] ? res.begin() : res.end() - 2, B[0]);
else res.insert(std::find(res.begin(), res.end(), r1), B[0]);
}
} else {
const int r1 = getNextLightest(A[0], A[1], A[2], B[0]);
res.insert(std::find(res.begin(), res.end(), r1), B[0]);
res.insert(std::find(res.begin(), res.end(), r2), B[1]);
const int r3 = getNextLightest(A[0], A[1], A[2], B[2]);
res.insert(r3 == A[0] ? res.end() : std::find(res.begin(), res.end(), r3), B[2]);
}
int gb[6];
for (int i = 0; i < 6; ++i) gb[i] = res[i];
answer(gb);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |