# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595554 | Apiram | Scales (IOI15_scales) | C++14 | 0 ms | 0 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) {
//1 2 3 4 5 6
// 5 - operations to get first and last value -> call median 4times then maximum or minimum 1 times
// 2 - median call to get middle value
// 3 call to do remaining
// 10 calls to sort
}
void orderCoins() {
vector<bool>got(7,false);
int a = getMedian(1, 2, 3);
got[a] = true;
a = getMedian(4,5,6);
got[a] = true;
for (int j = 0;j<2;++j){
vector<int>cur;
for (int i = 1;i<7;++i){
if (!got[i]){
cur.push_back(i);
}
}
a = getMedian(cur[0],cur[1],cur[2]);
got[a] = true;
}
vector<int>cur;
for (int i = 1;i<7;++i){
if (!got[a]){
cur.push_back(a);
}
}
a = getHeaviest(cur[0],cur[1],a);
vector<int>ans(6);
ans[0] = a;
if (a == cur[0]){
ans[5] = cur[1];
}
else{
ans[5] = cur[0];
}
cur.clear();
for (int i = 1;i<7;++i){
if (got[i])cur.push_back(i);
}
int b = getMedian(cur[0],cur[1],cur[2]);
a = getMedian(b,cur[3],ans[5]);
ans[3] = a;
got[a] = false;
cur.clear();
for (int i = 1;i<7;++i){
if (!got[i])cur.push_back(i);
}
a = getHeaviest(cur[0],cur[1],cur[2]);
ans[4] = a;
got[a] = true;
a = getMedian(cur[0],cur[1],cur[2]);
got[a] = true;
ans[2] = a;
for (int i = 1;i<6;++i){
if(!got[i])ans[1] = i;
}
answers(ans);
return;
}