# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
104275 | arman_ferdous | Scales (IOI15_scales) | C++17 | 4 ms | 512 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,2,3,4,5,6};
int a = 1, b = 2, c = 3;
int lo = getLightest(a,b,c);
int mid = getMedian(a,b,c), hi;
if(a != lo && a != mid) hi = a;
else if(b != lo && b != mid) hi = b;
else hi = c;
W[0] = lo, W[1] = mid, W[2] = hi;
a = 4, b = 5, c = 6;
lo = getLightest(a,b,c);
mid = getMedian(a,b,c);
if(a != lo && a != mid) hi = a;
else if(b != lo && b != mid) hi = b;
else hi = c;
W[3] = lo, W[4] = mid, W[5] = hi;
vector<int> L(3), R(3), soln;
for(int i = 0; i < 3; i++) L[i] = W[i];
for(int i = 0; i < 3; i++) R[i] = W[i+3];
for(;;) {
if(L.empty()) {
while(!R.empty()) {
soln.push_back(R.back());
R.pop_back();
} break;
}
if(R.empty()) {
while(!L.empty()) {
soln.push_back(L.back());
L.pop_back();
} break;
}
if(L.size() < 2 && R.size() < 2) {
int got = getLightest(L[0], R[0], soln.back());
if(got == L[0]) {
soln.push_back(R[0]);
soln.push_back(L[0]);
} else {
soln.push_back(L[0]);
soln.push_back(R[0]);
} R.pop_back(); L.pop_back();
break;
}
if(L.size() > 1) {
int got = getHeaviest(L[L.size()-2], L.back(), R.back());
if(got == L.back()) {
soln.push_back(L.back());
L.pop_back();
} else {
soln.push_back(R.back());
R.pop_back();
}
}
else {
int got = getHeaviest(L.back(), R.back(), R[R.size()-2]);
if(got == L.back()) {
soln.push_back(L.back());
L.pop_back();
} else {
soln.push_back(R.back());
R.pop_back();
}
}
}
for(int i = 0; i < 6; i++) W[i] = soln[5-i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |