# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1121092 | SalihSahin | Scales (IOI15_scales) | C++14 | 2 ms | 508 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 <bits/stdc++.h>
#define pb push_back
using namespace std;
#include "scales.h"
void init(int T) {
/* ... */
}
void orderCoins() {
int W[6];
int x = getLightest(1, 2, 3);
vector<int> rem;
for(int i = 1; i <= 3; i++){
if(i != x) rem.pb(i);
}
int y = getHeaviest(rem[0], rem[1], 4);
vector<int> rem2;
for(int i = 1; i <= 4; i++){
if(i != y && i != x) rem2.pb(i);
}
int z = getMedian(rem2[0], rem2[1], x);
vector<int> l = {-1, -1, -1, y};
if(z == x){
l[1] = x;
l[2] = rem2[0];
l[0] = rem2[1];
}
else if(z == rem2[0]){
l[0] = x;
l[1] = z;
l[2] = rem2[1];
}
else{
l[0] = x;
l[1] = rem2[1];
l[2] = rem2[0];
}
//for(int i = 0; i < 4; i++) cout<<l[i]<<" ";
//cout<<endl;
// 1, 2, 3, 4 ---- 5 ve 6 kaldı 3 islemde
vector<int> l2 = {-1, -1, -1, -1, -1};
int k = getMedian(l[0], l[2], 5);
if(k == 5){
int k2 = getMedian(l[0], l[1], 5);
if(k2 == l[1]) l2 = {l[0], l[1], 5, l[2], l[3]};
else l2 = {l[0], 5, l[1], l[2], l[3]};
}
else if(k == l[0]) l2 = {5, l[0], l[1], l[2], l[3]};
else if(k == l[2]){
int k2 = getMedian(l[2], l[3], 5);
if(k2 == l[3]) l2 = {l[0], l[1], l[2], l[3], 5};
else l2 = {l[0], l[1], l[2], 5, l[3]};
}
l = l2;
//for(int i = 0; i < 5; i++) cout<<l[i]<<" ";
//cout<<endl;
vector<int> res = {-1, -1, -1, -1, -1, -1};
k = getMedian(l[1], l[3], 6);
if(k == 6){
int k2 = getMedian(l[1], l[2], 6);
if(k2 == l[2]) res = {l[0], l[1], l[2], 6, l[3], l[4]};
else res = {l[0], l[1], 6, l[2], l[3], l[4]};
}
else if(k == l[1]){
int k2 = getMedian(l[0], l[1], 6);
if(k2 == l[0]) res = {6, l[0], l[1], l[2], l[3], l[4]};
else res = {l[0], 6, l[1], l[2], l[3], l[4]};
}
else if(k == l[3]){
int k2 = getMedian(l[3], l[4], 6);
if(k2 == l[4]) res = {l[0], l[1], l[2], l[3], l[4], 6};
else res = {l[0], l[1], l[2], l[3], 6, l[4]};
}
for(int i = 0; i < 6; i++){
W[i] = res[i];
}
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |