# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31262 | top34051 | Scales (IOI15_scales) | C++14 | 0 ms | 2024 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;
vector<int> p,a,b,tp;
void init(int T) {
}
void orderCoins() {
int i,x,temp,mn,t1,t2;
int W[] = {1, 2, 3, 4, 5, 6};
a.clear(); b.clear();
t1 = getLightest(1,2,3);
t2 = getLightest(4,5,6);
for(i=1;i<=3;i++) {
if(i!=t1 && i!=t2) {
mn = getLightest(i,t1,t2);
break;
}
}
for(i=1;i<=3;i++) if(i!=mn) a.push_back(i);
for(i=4;i<=6;i++) if(i!=mn) b.push_back(i);
if(a.size()>b.size()) swap(a,b);
temp = getLightest(b[0],b[1],b[2]);
for(i=0;i<3;i++) if(b[i]==temp) swap(b[i],b[0]);
temp = getMedian(b[0],b[1],b[2]);
for(i=0;i<3;i++) if(b[i]==temp) swap(b[i],b[1]);
p.clear();
p.push_back(mn);
for(i=0;i<b.size();i++) p.push_back(b[i]);
// cerr << "p : ";
// for(i=0;i<p.size();i++) cerr << p[i] << " ";
// cerr << "\n";
//
// cerr << "a : ";
// for(i=0;i<a.size();i++) cerr << a[i] << " ";
// cerr << "\n";
x = a[0];
temp = getNextLightest(p[0],p[1],p[2],x);
if(temp==p[0]) {
temp = getNextLightest(p[0],p[1],p[3],x);
if(temp==p[0]) p.push_back(x);
else {
tp.clear();
for(i=0;i<p.size();i++) {
if(temp==p[i]) tp.push_back(x);
tp.push_back(p[i]);
}
p = tp;
}
}
else {
tp.clear();
for(i=0;i<p.size();i++) {
if(temp==p[i]) tp.push_back(x);
tp.push_back(p[i]);
}
p = tp;
}
x = a[1];
temp = getNextLightest(p[0],p[1],p[2],x);
if(temp==p[0]) {
temp = getNextLightest(p[0],p[3],p[4],x);
if(temp==p[0]) p.push_back(x);
else {
tp.clear();
for(i=0;i<p.size();i++) {
if(temp==p[i]) tp.push_back(x);
tp.push_back(p[i]);
}
p = tp;
}
}
else {
tp.clear();
for(i=0;i<p.size();i++) {
if(temp==p[i]) tp.push_back(x);
tp.push_back(p[i]);
}
p = tp;
}
for(i=0;i<6;i++) W[i] = p[i];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |