# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595914 | Apiram | Scales (IOI15_scales) | C++14 | 3 ms | 468 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
// 2 call to do remaining
// 9 calls to sort
}
//3 4 6 2 1 5
void orderCoins() {
vector<int>ans = {1,2,3,4,5,6};
auto exchange = [&](int i,int j,int p,int q,int r){
int index = -1;
for (auto x:{p,q,r}){
if (ans[x] == i){index = j;ans[x] = j;}
else if (ans[x] == j)ans[x] =i;
}
return index;
};
// 3 -> 3 2 1 4 5 6
int a = getLightest(ans[0],ans[1],ans[2]);
exchange(a,ans[0],0,1,2);
int b = getLightest(ans[3],ans[4],ans[5]);
exchange(a,ans[3],3,4,5);
int c = getLightest(ans[0],ans[1],ans[3]);
if (c == ans[0]){
exchange(ans[3],ans[1],0,1,3);
}
else{
exchange(ans[0],ans[1],0,1,3);
exchange(ans[3],ans[0],0,1,3);
}
a = getHeaviest(ans[5],ans[2],ans[3]);
exchange(a,ans[5],5,2,3);
a = getHeaviest(ans[1],ans[4],ans[5]);
exchange(a,ans[5],1,4,5);
a = getHeaviest(ans[2],ans[3],ans[4]);
exchange(a,ans[4],2,3,4);
a = getLightest(ans[2],ans[3],ans[4]);
exchange(a,ans[2],2,3,4);
answer(ans.data());
return;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |