# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604329 | 8e7 | 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.
//Challenge: Accepted
#include <bits/stdc++.h>
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cout << *l << " ", l++;
cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
#include "scales.h"
void init(int T) {
/* ... */
}
void orderCoins() {
int n = 3;
int a[3] = {1, 2, 3}, b[3] = {4, 5, 6};
int ret[6];
int ind = find(a, a + n, getLightest(a[0], a[1], a[2])) - a;
swap(a[ind], a[0]);
ind = find(b, b + n, getLightest(b[0], b[1], b[2])) - b;
swap(b[ind], b[0]);
//a[0] < a[1], a[2], b[0] < b[1], b[2];
int tmp = getHeaviest(a[0], b[1], b[2]);
if (tmp == a[0]) {
ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b;
swap(b[ind], b[2]);
ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a;
swap(a[ind], a[2]);
int r[6] = {b[0], b[1], b[2], a[0], a[1], a[2]};
answer(r);
return;
} else {
if (tmp == b[1]) swap(b[1], b[2]);
}
tmp = getHeaviest(b[0], a[1], a[2]);
if (tmp == b[0]) {
ind = find(b, b + n, getHeaviest(b[0], b[1], b[2])) - b;
swap(b[ind], b[2]);
ind = find(a, a + n, getHeaviest(a[0], a[1], a[2])) - a;
swap(a[ind], a[2]);
int r[6] = {a[0], a[1], a[2], b[0], b[1], b[2]};
answer(r);
return;
} else {
if (tmp == a[1]) swap(a[1], a[2]);
}
int pos[3] = {0, 0, 0};
bool det = 0;
for (int i = 0;i < 3;i++) {
ind = getNextLightest(a[0], a[1], a[2], b[i]);
if (ind == a[1]) {
pos[i] = 1;
} else if (ind == a[2]) {
pos[i] = 2;
} else {
if (i == 0) pos[i] = 0;
else if (i == 2) pos[i] = 3;
else {
det = 1;
}
}
}
if (det) {
if (pos[0] > 0) pos[1] = 3;
else if (pos[2] < 3) pos[1] = 0;
else {
if (getHeaviest(a[0], a[2], b[1]) == b[1]) pos[1] = 3;
else pos[1] = 0;
}
}
ind = 0;
int cur = 0;
for (int i = 0;i < 3;i++) {
while (ind < 3 && pos[ind] <= i) ret[cur++] = b[ind++];
ret[cur++] = a[i];
}
while (ind < 3) ret[cur++] = b[ind++];
answer(ret);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |