# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47627 | RezwanArefin01 | Scales (IOI15_scales) | C++17 | 2 ms | 616 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 <bits/stdc++.h>
using namespace std;
void init(int T) {}
void orderCoins() {
int w[6] = {-1, -1, -1, -1, -1, -1};
deque<int> f = { getLightest(1, 2, 3), 0, getHeaviest(1, 2, 3) };
f[1] = f[0] ^ f[2];
deque<int> s = { getLightest(4, 5, 6), 0, getHeaviest(4, 5, 6) };
s[1] = (3 + ((s[0] - 3) ^ (s[2] - 3)));
w[0] = getLightest(s[0], f[0], s[1]);
w[5] = getHeaviest(s[2], f[2], f[1]);
if(w[0] == f[0]) f.pop_front();
if(w[0] == s[0]) s.pop_front();
if(w[5] == f[2]) f.pop_back();
if(w[5] == s[2]) s.pop_back();
if(f.size() == s.size()) {
w[1] = getLightest(f[0], f[1], s[0]);
if(w[1] == f[0]) {
int x = getMedian(f[1], s[0], s[1]);
if(x == f[1]) {
w[2] = s[0], w[3] = f[1], w[4] = s[1];
} else if (x == s[0]) {
w[2] = f[1], w[3] = s[0], w[4] = s[1];
} else {
w[2] = s[0], w[3] = s[1], w[4] = f[1];
}
} else {
int x = getMedian(f[0], f[1], s[1]);
if(x == f[0]){
w[2] = s[1], w[3] = f[0], w[4] = f[1];
} else if(x == f[1]) {
w[2] = f[0], w[3] = f[1], w[4] = s[1];
} else {
w[2] = f[0], w[3] = s[1] , w[4] = f[1];
}
}
} else {
if(f.size() < s.size()) {
int x = getMedian(f[0], s[0], s[2]);
if(x == s[0]) {
w[1] = f[0], w[2] = s[0], w[3] = s[1], w[4] = s[2];
} else if(x == s[2]) {
w[1] = s[0], w[2] = s[1], w[3] = s[2], w[4] = f[0];
} else {
w[1] = s[0], w[4] = s[2];
w[3] = getHeaviest(f[0], s[0], s[1]);
w[2] = w[3] ^ f[0] ^ s[1];
}
} else {
int x = getMedian(f[0], f[2], s[0]);
if(x == f[0]) {
w[1] = s[0], w[2] = f[0], w[3] = f[1], w[4] = f[2];
} else if(x == f[2]) {
w[1] = f[0], w[2] = f[1], w[3] = f[2], w[4] = s[0];
} else {
w[1] = f[0], w[4] = f[2];
w[3] = getHeaviest(f[0], f[1], s[0]);
w[2] = w[3] ^ f[1] ^ s[0];
}
}
}
answer(w);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |