# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
752513 | phoebe | Scales (IOI15_scales) | C++17 | 1 ms | 244 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;
void init(int t){
// wat why do we need this?
}
void orderCoins(){
// int h[6] = {0};
// answer(h); return;
vector<int> x = {1, 2, 3, 4, 5, 6};
int total = 1 + 2 + 3;
// sort first half
int mn = getLightest(1, 2, 3);
int mx = getHeaviest(1, 2, 3);
int med = total - mn - mx;
x[0] = mn; x[1] = med; x[2] = mx;
// sort second half
total = 4 + 5 + 6;
mn = getLightest(4, 5, 6);
mx = getHeaviest(4, 5, 6);
med = total - mn - mx;
x[3] = mn; x[4] = med; x[5] = mx;
vector<int> re;
if (getLightest(x[0], x[3], x[5]) != x[3]){
swap(x[0], x[3]); swap(x[1], x[4]); swap(x[2], x[5]);
}
// x[0] > x[3]
int cur = 3;
for (int i = 0; i < 3; i++){
int med = getNextLightest(x[3], x[4], x[5], x[i]);
if (med == x[3]){ // all smaller than x[i]
while (cur < 6) re.push_back(x[cur++]);
}
else{
while (x[cur] != med) re.push_back(x[cur++]);
}
re.push_back(x[i]);
}
while (cur < 6) re.push_back(x[cur++]);
int w[6]; for (int i = 0; i < 6; i++) w[i] = re[i];
answer(w);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |