# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
837197 | mindiyak | Scales (IOI15_scales) | C++14 | 1 ms | 340 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 <vector>
using namespace std;
void init(int T) {
/* ... */
}
void orderCoins() {
int aMax = getHeaviest(1,2,3);
int aMin = getLightest(1,2,3);
int bMax = getHeaviest(4,5,6);
int bMin = getLightest(4,5,6);
vector<int> a = {aMin};
for(int x:{1,2,3}){
if(x==aMax or x==aMin)continue;
a.push_back(x);
}a.push_back(aMax);
vector<int> b = {bMin};
for(int x:{4,5,6}){
if(x==bMax or x==bMin)continue;
b.push_back(x);
}b.push_back(bMax);
vector<int> ans;
vector<int> to;
int x = getLightest(a[0],b[0],a[1]);
ans.push_back(x);
if(x<=3){//a[1,2] b[0,1,2]
x = getLightest(a[1],b[0],a[2]);
ans.push_back(x);
if(x<=3){//a[2] b[0,1,2]
x = getLightest(b[1],b[0],a[2]);
ans.push_back(x);
if(x<=3){//b[0,1,2]
to = b;
}else{//a[2] b[1,2]
to = vector<int> (b.begin()+1,b.end());
to.push_back(a[2]);
}
}else{//a[1,2] b[1,2]
x = getLightest(b[1],a[1],a[2]);
ans.push_back(x);
if(x<=3){//a[2] b[1,2]
to = vector<int> (b.begin()+1,b.end());
to.push_back(a[2]);
}else{//a[1,2] b[2]
to = vector<int> (a.begin()+1,a.end());
to.push_back(b[2]);
}
}
}else{//a[0,1,2] b[1,2]
x = getLightest(a[0],b[1],a[2]);
ans.push_back(x);
if(x<=3){//a[1,2] b[1,2]
x = getLightest(b[1],b[2],a[1]);
ans.push_back(x);
if(x<=3){//a[2] b[1,2]
to = vector<int> (b.begin()+1,b.end());
to.push_back(a[2]);
}else{//a[1,2] b[2]
to = vector<int> (a.begin()+1,a.end());
to.push_back(b[2]);
}
}else{//a[0,1,2] b[2]
x = getLightest(b[2],a[1],a[0]);
ans.push_back(x);
if(x<=3){//a[1,2] b[2]
to = vector<int> (a.begin()+1,a.end());
to.push_back(b[2]);
}else{//a[0,1,2]
to = a;
}
}
}
x = getLightest(to[0],to[1],to[2]);
ans.push_back(x);
int MX = getHeaviest(to[0],to[1],to[2]);
for(int y:to){
if(y==x or y==MX)continue;
ans.push_back(y);
}ans.push_back(MX);
int intans[6];
for(int i=0;i<6;i++)intans[i] = ans[i];
answer(intans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |