# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404683 | Dakto | Scales (IOI15_scales) | C++17 | 1 ms | 204 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) {
}
bool contains(vector<int>& v, int x){
return find(v.begin(),v.end(), x)!=v.end();
}
vector<int> addany(vector<int> s, vector<int> p){
set<int> st(begin(s),end(s));
for(auto i:p){
st.insert(i);
if(st.size()>=3) break;
}
return vector<int>(st.begin(),st.end());
}
void orderCoins() {
vector<int> res,p={1,2,3,4,5,6};
int m1=getLightest(1,2,3);
int m2=getLightest(4,5,6);
auto a=addany({m1,m2},p);
int m=getLightest(a[0],a[1],a[2]);
res.push_back(m);
p.erase(find(p.begin(),p.end(),m));
if(m==m1){
int r=getLightest(p[0],p[1],m2);
res.push_back(r);
p.erase(find(p.begin(),p.end(),r));
}
else{
int r=getLightest(p[3],p[4],m1);
res.push_back(r);
p.erase(find(p.begin(),p.end(),r));
}
int x1=getLightest(p[0],p[1],p[2]);
int x2=getLightest(p[1],p[2],p[3]);
if(x1==x2){
res.push_back(x1);
p.erase(find(p.begin(),p.end(),x1));
auto x=getHeaviest(p[0],p[1],p[2]);
auto y=getMedian(p[0],p[1],p[2]);
p.erase(find(p.begin(),p.end(),x));
p.erase(find(p.begin(),p.end(),y));
res.push_back(p[0]);
res.push_back(y);
res.push_back(x);
}
else{
auto a=addany({x1,x2},p);
int r=getLightest(a[0],a[1],a[2]);
res.push_back(r);
p.erase(find(p.begin(),p.end(),r));
if(r==x1){
res.push_back(x2);
p.erase(find(p.begin(),p.end(),x2));
}
else{
res.push_back(x1);
p.erase(find(p.begin(),p.end(),x1));
}
r=getHeaviest(p[0],p[1],res[0]);
p.erase(find(p.begin(),p.end(),r));
res.push_back(p[0]);
res.push_back(r);
}
int out[6];
for(int i=0; i<6; i++) out[i]=res[i];
answer(out);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |