# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
760916 | Ahmed57 | Scales (IOI15_scales) | C++17 | 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){
return ;
}
//int ww[7];
//int getHeaviest(int A, int B, int C);
//int getLightest(int A, int B, int C);
//int getMedian(int A, int B, int C);
//int getNextLightest(int A, int B, int C, int D);
//void answer(int W[6]);
vector<int> ers(vector<int> v,int x){
vector<int> res;
for(auto i:v){
if(i==x)continue;
res.push_back(i);
}
return res;
}
void orderCoins(){
int ss = 0;
vector<int> rem;
int ans[6] = {0};
for(int i = 1;i<=6;i++)rem.push_back(i);
random_shuffle(rem.begin(),rem.end());
int x = getLightest(rem[0],rem[1],rem[2]);
int y = getLightest(rem[3],rem[4],rem[5]);
int z = getLightest(x,y,((x!=rem[0]&&y!=rem[0])?rem[0]:((x!=rem[1]&&y!=rem[1])?rem[1]:rem[2])));
ss = (z==x?1:0);
ans[0] = z;
rem = ers(rem,z);
if(ss)x = getLightest(rem[0],rem[1],rem[2]);
if(!ss)y = getLightest(rem[2],rem[3],rem[4]);
if(x==y){
z = x;
ss = 3;
}else{
z = getLightest(x,y,((x!=rem[0]&&y!=rem[0])?rem[0]:((x!=rem[1]&&y!=rem[1])?rem[1]:rem[2])));
ss = (z==x?1:0);
}
ans[1] = z;
rem = ers(rem,z);
if(ss>0)x = getLightest(rem[0],rem[1],rem[2]);
if(ss==0||ss==3)y = getLightest(rem[1],rem[2],rem[3]);
long long mi = 1e9;
if(x!=y){
z = getLightest(x,y,((x!=rem[0]&&y!=rem[0])?rem[0]:((x!=rem[1]&&y!=rem[1])?rem[1]:rem[2])));
if(z==rem[0]){
mi = y;
}else{
mi = x;
}
}else {
z = x;
mi = getLightest(rem[0],(z==rem[1]?rem[2]:rem[1]),rem[3]);
}
ans[2] = z;
rem = ers(rem,z);
ans[3] = mi;
z = getHeaviest(rem[0],rem[1],rem[2]);
rem = ers(rem,mi);
ans[5] = z;
rem = ers(rem,z);
ans[4] = rem[0];
int he[] = {ans[0],ans[1],ans[2],ans[3],ans[4],ans[5]};
answer(he);
return ;
}
/*
int main(){
ww[1] = 2 , ww[2] = 1, ww[3] = 3 , ww[4] = 4, ww[5] =5 , ww[6] = 6;
orderCoins();
}*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |