# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595582 | Apiram | Scales (IOI15_scales) | C++14 | 1 ms | 212 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
}
//3 4 6 2 1 5
void orderCoins() {
vector<bool>got(7,false);
int a = getMedian(1, 2, 3);
//2
got[a] = true;
a = getMedian(4,5,6);
got[a] = true;
//6
for (int j = 0;j<2;++j){
vector<int>cur;
for (int i = 1;i<7;++i){
if (!got[i]){
cur.push_back(i);
//4 1
}
}
a = getMedian(cur[0],cur[1],cur[2]);
got[a] = true;
}
vector<int>cur;
for (int i = 1;i<7;++i){
if (!got[i]){
cur.push_back(i);
}
}
a = getHeaviest(cur[0],cur[1],a);
//3 1 5
int ans[6];
ans[5] = a;//5
if (a == cur[0]){
ans[0] = cur[1];
}
else{
ans[0] = cur[0];
}
// 3
cur.clear();
for (int i = 1;i<7;++i){
if (got[i])cur.push_back(i);
}
//2 6 4 - > 6
int b = getHeaviest(cur[0],cur[1],cur[2]);
//6 1 5
a = getHeaviest(b,cur[3],ans[5]);
ans[4] = 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[3] = a;
got[a] = false;
a = getMedian(cur[0],cur[1],cur[2]);
got[a] = false;
ans[2] = a;
for (int i = 1;i<7;++i){
if(!got[i])ans[1] = i;
}
answer(ans);
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |