# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
791888 | jasmin | 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) {
/* ... */
}
void orderCoins() {
//find smallest
int small1=getLightest(1, 2, 3);
set<int> group1={1, 2, 3};
group1.erase(small1);
int small2=getLightest(4, 5, 6);
set<int> group2={4, 5, 6};
group2.erase(small2);
int middle=getMedian(small1, small2, *group1.begin());
vector<int> order;
if(middle==small1){
order={small2, small1, *group1.begin()};
group1.erase(*group1.begin());
swap(group1, group2);
swap(small1, small2);
}
else if(middle==small2){
order={small1, small2, *group1.begin()};
group1.erase(*group1.begin());
}
else{
order={small1, *group1.begin(), small2};
group1.erase(*group1.begin());
}
//finish group 1
//we only know that they are larger than the first one
middle=getMedian(order[1], order[2], *group1.begin());
if(middle==order[1]){
order.push_back(order[2]);
order[2]=order[1];
order[1]=*group1.begin();
}
else if(middle==order[2]){
order.push_back(*group1.begin());
}
else{
order.push_back(order[2]);
order[2]=*group1.begin();
}
group1.erase(*group1.begin());
if(!group1.empty()){
int elem=*group1.begin();
if(getLightest(order[1], order[2], elem)==elem){
order.push_back(order[3]);
order[3]=order[2];
order[2]=order[1];
order[1]=elem;
}
else{
middle=getMedian(order[2], order[3], elem);
if(middle==order[2]){
order.push_back(order[3]);
order[3]=order[2];
order[2]=elem;
}
else if(middle==order[3]){
order.push_back(elem);
}
else{
order.push_back(order[3]);
order[3]=elem;
}
}
group1.erase(elem);
}
//finish group 2
if(group2.size()==2){
//wir sind grösser als element 1
int elem=*group2.begin();
middle=getMedian(order[2], order[3], elem);
if(middle==order[2]){
order.push_back(order[3]);
order[3]=order[2];
order[2]=elem;
}
else if(middle==order[3]){
order.push_back(elem);
}
else{
order.push_back(order[3]);
order[3]=elem;
}
group2.erase(elem);
}
int elem=*group2.begin();
if(getLightest(order[2], order[3], elem)==elem){
order.push_back(order[4]);
order[4]=order[3];
order[3]=order[2];
order[2]=elem;
}
else{
middle=getMedian(order[3], order[4], elem);
if(middle==order[3]){
order.push_back(order[4]);
order[4]=order[3];
order[3]=elem;
}
else if(middle==order[4]){
order.push_back(elem);
}
else{
order.push_back(order[4]);
order[4]=elem;
}
}
int W[] = {1, 2, 3, 4, 5, 6};
for(int i=0; i<6; i++){
W[i]=order[i];
}
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |