# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163616 | shenxy | Scales (IOI15_scales) | C++11 | 3 ms | 508 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 <cstdio>
#include <algorithm>
#include <deque>
using namespace std;
void init(int T) {
}
void orderCoins() {
int W[6] = {1, 2, 3, 4, 5, 6};
int x = getLightest(1, 2, 3);
W[0] = x;
x = getHeaviest(1, 2, 3);
W[2] = x;
for (int i = 1; i <= 3; ++i) {
if (W[0] != i && W[2] != i) W[1] = i;
}
x = getLightest(4, 5, 6);
W[3] = x;
x = getHeaviest(4, 5, 6);
W[5] = x;
for (int i = 4; i <= 6; ++i) {
if (W[3] != i && W[5] != i) W[4] = i;
}
deque<int> ans;
if (getHeaviest(W[0], W[2], W[5]) == W[2]) {
swap(W[0], W[3]);
swap(W[1], W[4]);
swap(W[2], W[5]);
}
int ptr = 5;
for (int i = 2; i >= 0; --i) {
x = getNextLightest(W[3], W[4], W[5], W[i]);
if (x == W[5]) {
while (ptr > 4) ans.push_front(W[ptr--]);
} else if (x == W[4]) {
while (ptr > 3) ans.push_front(W[ptr--]);
} else {
while (ptr > 2) ans.push_front(W[ptr--]);
for (; i >= 0; --i) ans.push_front(W[i]);
for (int j = 0; j < 6; ++j) W[j] = ans[j];
answer(W);
return;
}
ans.push_front(W[i]);
}
while (ptr > 2) ans.push_front(W[ptr--]);
for (int i = 0; i < 6; ++i) W[i] = ans[i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |