# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434716 | pliam | Scales (IOI15_scales) | C++14 | 1 ms | 292 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;
int known[7];
int prev_[6];
void init(int T) {
/* ... */
}
void orderCoins() {
for(int i=1;i<=6;i++){
known[i]=0;
}
int W[6];
int l1,m1,h1,l2,m2,h2;
l1=getLightest(1,2,3);
l2=getLightest(4,5,6);
h1=getHeaviest(1,2,3);
h2=getHeaviest(4,5,6);
for(int i=1;i<=3;i++){
if(i!=l1&&i!=h1) m1=i;
}
for(int i=4;i<=6;i++){
if(i!=l2&&i!=h2) m2=i;
}
int a=getHeaviest(l1,h1,h2);
if(a==h2){
swap(l1,l2);
swap(m1,m2);
swap(h1,h2);
}
prev_[h1]=m1;
prev_[m1]=l1;
prev_[l1]=0;
//now h1 is the heaviest
vector<int> sorted;
sorted.push_back(l1);
sorted.push_back(m1);
sorted.push_back(h1);
a=getNextLightest(l1,m1,h1,h2);
if(a==l1){
sorted.insert(sorted.begin(),h2);
sorted.insert(sorted.begin(),m2);
sorted.insert(sorted.begin(),l2);
for(int i=0;i<=5;i++){
W[i]=sorted[i];
}
answer(W);
return;
}
auto it=sorted.begin();
for(int i=0;i<sorted.size();i++,it++){
if(((prev_[a]==0)&&(i==0))||((i>0)&&sorted[i-1]==prev_[a])){
sorted.insert(it,h2);
break;
}
}
int b=getNextLightest(l1,m1,h1,m2);
if(b==l1){
sorted.insert(sorted.begin(),m2);
sorted.insert(sorted.begin(),l2);
for(int i=0;i<=5;i++){
W[i]=sorted[i];
}
answer(W);
return;
}
it=sorted.begin();
for(int i=0;i<sorted.size();i++,it++){
if(((prev_[b]==0)&&(i==0))||((i>0)&&sorted[i-1]==prev_[b])){
sorted.insert(it,m2);
break;
}
}
int c=getNextLightest(l1,m1,h1,l2);
it=sorted.begin();
for(int i=0;i<sorted.size();i++,it++){
if(((prev_[c]==0)&&(i==0))||((i>0)&&sorted[i-1]==prev_[c])){
sorted.insert(it,l2);
break;
}
}
for(int i=0;i<=5;i++){
W[i]=sorted[i];
}
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |