# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
131347 | antimirage | Scales (IOI15_scales) | C++14 | 3 ms | 376 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 "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
void init(int T) {
}
void orderCoins() {
int ans[6];
int res1[3] = {1, 2, 3}, res2[3] = {4, 5, 6};
res1[0] = getLightest(1, 2, 3);
res2[0] = getLightest(4, 5, 6);
res1[2] = getHeaviest(1, 2, 3);
res2[2] = getHeaviest(4, 5, 6);
for (int i = 1; i <= 3; i++) {
if (res1[0] != i && res1[2] != i) {
res1[1] = i;
}
if (res2[0] != i + 3 && res2[2] != i + 3) {
res2[1] = i + 3;
}
}
int i = 0, j = 0;
for (int k = 0; k < 6; k++) {
if (i == 3) {
ans[k] = res2[j++];
continue;
}
if (j == 3) {
ans[k] = res1[i++];
continue;
}
if (i == 2 && j == 2) {
ans[k + 1] = getHeaviest(res1[i], res2[j], ans[0]);
if (ans[k + 1] == res1[i])
ans[k] = res2[j];
else
ans[k] = res1[i];
answer(ans);
return;
}
int m;
if (i == 2) {
m = getMedian(res1[i], res2[j], res2[j + 1]);
if (res1[i] == m) {
ans[k] = res2[j];
k++;
j++;
ans[k] = res1[i];
i++;
} else if (res2[j] == m) {
ans[k] = res1[i];
i++;
} else {
ans[k] = res2[j];
k++;
j++;
ans[k] = res2[j];
j++;
}
}
else {
m = getMedian(res1[i], res1[i + 1], res2[j]);
if (res2[j] == m) {
ans[k] = res1[i];
k++;
i++;
ans[k] = res2[j];
j++;
} else if (res1[i] == m) {
ans[k] = res2[j];
j++;
} else {
ans[k] = res1[i];
k++;
i++;
ans[k] = res1[i];
i++;
}
}
}
answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |