# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587102 | keta_tsimakuridze | Scales (IOI15_scales) | C++17 | 1 ms | 296 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) {
/* ... */
}
int A[55];
void orderCoins() {
vector<int> x;
vector<int> v; for(int i = 1; i < 7; i++) v.push_back(i);
random_shuffle(v.begin(), v.end());
random_shuffle(v.begin(), v.end());
random_shuffle(v.begin(), v.end());
for(int i = 1; i < 7; i++) A[i] = v[i - 1];
int a = getLightest(A[1], A[2], A[3]), b = getHeaviest(A[1], A[2], A[3]);
x.push_back(a); x.push_back(A[1] + A[2] + A[3] - a - b); x.push_back(b);
// 4
a = getNextLightest(A[1], A[2], A[3], A[4]);
if(a != x[0]) {
vector<int> xn;
for(int i = 0; i < x.size(); i++) {
if(x[i] == a) xn.push_back(A[4]);
xn.push_back(x[i]);
}
x = xn;
} else {
if(getHeaviest(x[1], x[2], A[4]) == A[4]) x.push_back(A[4]);
else {
vector<int> xn;
xn.push_back(A[4]);
for(int i = 0; i < x.size(); i++) xn.push_back(x[i]);
x = xn;
}
}
// 5
a = getNextLightest(x[0], x[1], x[2], A[5]);
if(a != x[0]) {
vector<int> xn;
for(int i = 0; i < x.size(); i++) {
if(x[i] == a) xn.push_back(A[5]);
xn.push_back(x[i]);
}
x = xn;
} else {
if(getHeaviest(x[1], x[2], A[5]) == A[5]) {
if(getHeaviest(x[2], x[3], A[5]) == A[5]) {
x.push_back(A[5]);
} else {
vector<int> xn;
for(int i = 0; i < x.size(); i++) {
if(i == 3) xn.push_back(A[5]);
xn.push_back(x[i]);
}
x = xn;
}
} else {
vector<int> xn;
xn.push_back(A[5]);
for(int i = 0; i < x.size(); i++) xn.push_back(x[i]);
x = xn;
}
}
// 6
a = getNextLightest(x[1], x[2], x[3], A[6]);
if(a != x[1]) {
vector<int> xn;
for(int i = 0; i < x.size(); i++) {
if(x[i] == a) xn.push_back(A[6]);
xn.push_back(x[i]);
}
x = xn;
} else if(getHeaviest(x[2], x[3], A[6]) == A[6]) {
if(getHeaviest(x[3], x[4], A[6]) == A[6]) {
x.push_back(A[6]);
} else {
x.push_back(A[6]);
swap(x[5], x[4]);
}
} else {
vector<int> xn;
xn.push_back(A[6]);
for(int i = 0; i < x.size(); i++) xn.push_back(x[i]);
x = xn;
if(getLightest(x[0], x[1], x[2]) != A[6]) swap(x[0], x[1]);
}
// for(int i = 0; i < 6; i++) cout << x[i] << " ";
// cout << endl;
int W[] = {x[0], x[1], x[2], x[3], x[4], x[5]};
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |