# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
914274 | Itamar | Scales (IOI15_scales) | C++14 | 0 ms | 0 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.
void init(int T) {
}
#include "scales.h"
#include <vector>
using namespace std;
#define vi vector<int>
#include <set>
#include <algorithm>
void orderCoins() {
vi vec = { 1,2,3 };
vi v;
v.push_back(getLightest(1, 2, 3));
swap(vec[v[0]-1], vec.back());
vec.pop_back();
vec.push_back(4);
int a = getHeaviest(4, vec[1], vec[0]);
if (a == 4) {
if (getHeaviest(v[0], vec[0], vec[1]) == vec[0]) {
v = { v[0],vec[1],vec[0],vec[2] };
}
else {
v = { v[0],vec[0],vec[1],vec[2] };
}
}
else{
if (a == vec[0])swap(vec[1], vec[0]);
v.push_back(vec[0]); v.push_back(vec[1]);
int b = getMedian(v[1], v[0], vec[2]);
int in;
if (b == v[0])in = 0;
else if (b == v[1])in = 2;
else in = 1;
vi vt;
int i = 4;
for (int j = 0; j < in; j++)vt.push_back(v[j]);
vt.push_back(i);
for (int j = in; j < i - 1; j++)vt.push_back(v[j]);
v = vt;
}
for (int i = 5; i <= 6; i++) {
vi vt;
int an = getMedian(v[1], v[2], i);
int in;
if (an == i) {
in = 2;
}
else if(an==v[1]) {
int ant = getMedian(v[0], v[1], i);
if (ant == v[0]) {
in = 0;
}
else in = 1;
}
else {
int ant = getMedian(v[i - 3], v[i - 2], i);
if (ant == i)in = i - 2;
else if (ant == v[i - 2])in = i - 1;
else in = i - 3;
}
for (int j = 0; j < in; j++)vt.push_back(v[j]);
vt.push_back(i);
for (int j = in; j < i-1; j++)vt.push_back(v[j]);
v = vt;
}
int c[6];
for (int i = 0; i < 6; i++)c[i] = v[i];
answer(c);
}