# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1034361 | Zicrus | Scales (IOI15_scales) | C++17 | 1 ms | 432 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;
typedef long long ll;
void init(int T) {
/* ... */
}
void orderCoins() {
vector<int> res = {1, 2, 3, 4, 5, 6};
vector<int> G1 = {1, 2, 3, 4, 5, 6};
mt19937 mt(time(0));
shuffle(G1.begin(), G1.end(), mt);
vector<int> G = {0, G1[0], G1[1], G1[2], G1[3], G1[4], G1[5]};
int a = getHeaviest(G[1], G[2], G[3]);
int b = getHeaviest(G[4], G[5], G[6]);
int c = getHeaviest(a, b, G[1] == a || G[1] == b ? (G[2] == a || G[2] == b ? G[3] : G[2]) : G[1]);
res[5] = c;
bool cg = c == G[1] || c == G[2] || c == G[3];
int d = cg ? getHeaviest(b, G[1] == c ? G[3] : G[1], G[2] == c ? G[3] : G[2]) : getHeaviest(a, G[4] == c ? G[6] : G[4], G[5] == c ? G[6] : G[5]);
res[4] = d;
vector<int> s;
for (int i = 1; i <= 6; i++) {
if (G[i] != c && G[i] != d) s.push_back(G[i]);
}
int e = 0;
int idk = cg ? b : a;
if (s[0] == idk || s[1] == idk || s[2] == idk || s[3] == idk) {
int lol1 = cg ? (b == G[4] ? G[5] : G[4]) : (a == G[1] ? G[2] : G[1]);
int lol2 = cg ? (b == G[6] ? G[5] : G[6]) : (a == G[3] ? G[2] : G[3]);
if (s[0] != lol1 && s[0] != lol2 && s[0] != idk) s[3] = s[0];
if (s[1] != lol1 && s[1] != lol2 && s[1] != idk) s[3] = s[1];
if (s[2] != lol1 && s[2] != lol2 && s[2] != idk) s[3] = s[2];
s[0] = lol1; s[1] = lol2; s[2] = idk;
e = idk;
}
else {
e = getHeaviest(s[0], s[1], s[2]);
}
int e1 = e == s[0] ? s[2] : s[0], e2 = e == s[1] ? s[2] : s[1];
int f = getMedian(e, e1, s[3]);
if (f == e) {
res[3] = s[3];
res[2] = e;
res[1] = getMedian(e1, e2, e);
res[0] = res[1] == e1 ? e2 : e1;
}
else if (f == e1) {
res[3] = e;
res[1] = getMedian(e1, e2, s[3]);
res[2] = res[1] == e1 ? e2 : e1;
res[0] = res[1] == s[3] ? e2 : s[3];
}
else if (f == s[3]) {
res[3] = e;
res[1] = getMedian(e1, e2, s[3]);
res[2] = res[1] == s[3] ? e2 : s[3];
res[0] = res[1] == e1 ? e2 : e1;
}
int W[6] = {res[0], res[1], res[2], res[3], res[4], res[5]};
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |