# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70614 | Navick | Scales (IOI15_scales) | C++17 | 4 ms | 628 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>
#define F first
#define S second
#define pb push_back
#define pii pair<int, int>
using namespace std;
typedef long long ll;
const int maxN = 6;
vector <int> t;
int ans[maxN];
void init(int T) {
/* ... */
}
void orderCoins() {
int a = getHeaviest(1, 2, 3);
int b = getHeaviest(4, 5, 6);
t.resize(0);
for (int i=4; i<=6; i++)
if(i != b) t.pb(i);
int a1 = getHeaviest(a, t[0], t[1]);
t.resize(0);
for (int i=1; i<=3; i++)
if(i != a) t.pb(i);
int b1 = getHeaviest(b, t[0], t[1]);
if(a1 <= 3 && b1 <= 3)
{
ans[0] = a;
ans[1] = b1;
int c = 6;
for (int i=1; i<=3; i++)
if(i == a || i == b1) c -= i;
t.resize(0);
for (int i=4; i<=6; i++)
if(i != b) t.pb(i);
int g = getHeaviest(c, t[0], t[1]);
if(g == c)
{
ans[3] = getLightest(ans[0], b, c);
ans[2] = b + c - ans[3];
ans[5] = getLightest(ans[0], t[0], t[1]);
ans[4] = t[0] + t[1] - ans[5];
reverse(ans, ans + maxN);
answer(ans);
return ;
}else
{
ans[2] = b;
ans[3] = g;
int oth = t[0] + t[1] - g;
ans[5] = getLightest(ans[0], c, oth);
ans[4] = oth + c - ans[5];
reverse(ans, ans + maxN);
answer(ans);
return ;
}
}else if(a1 >= 4 && b1 >= 4)
{
ans[0] = b;
ans[1] = a1;
int c = 15;
for (int i=4; i<=6; i++)
if(i == b || i == a1) c -= i;
t.resize(0);
for (int i=1; i<=3; i++)
if(i != a) t.pb(i);
int g = getHeaviest(c, t[0], t[1]);
if(g == c)
{
ans[3] = getLightest(ans[0], a, c);
ans[2] = a + c - ans[3];
ans[5] = getLightest(ans[0], t[0], t[1]);
ans[4] = t[0] + t[1] - ans[5];
reverse(ans, ans + maxN);
answer(ans);
return ;
}else
{
ans[2] = a;
ans[3] = g;
int oth = t[0] + t[1] - g;
ans[5] = getLightest(ans[0], c, oth);
ans[4] = oth + c - ans[5];
reverse(ans, ans + maxN);
answer(ans);
return ;
}
}else
{
t.resize(0);
for (int i=1; i<=6; i++)
if(i != a && i != b) t.pb(i);
int c1 = getHeaviest(t[0], t[1], t[2]);
int r = t[3];
t.resize(0);
for (int i=1; i<=6; i++)
if(i != a && i != b && i != c1) t.pb(i);
int c2 = getLightest(t[0], t[1], t[2]);
if(c2 != r)
{
ans[5] = c2;
t.resize(0);
for (int i=1; i<=6; i++)
if(i != a && i != b && i != c2 && i != r && i != c1) t.pb(i);
int md = getMedian(t[0], c1, r);
if(md == c1) ans[2] = r, ans[3] = c1, ans[4] = t[0];
else if(md == t[0]) ans[2] = c1, ans[3] = t[0], ans[4] = r;
else ans[2] = c1, ans[3] = r, ans[4] = t[0];
}else
{
ans[5] = c2;
ans[2] = c1;
t.resize(0);
for (int i=1; i<=6; i++)
if(i != a && i != b && i != c1 && i != c2) t.pb(i);
int g = getLightest(c1, t[0], t[1]);
ans[4] = g;
ans[3] = t[0] + t[1] - g;
}
ans[0] = getHeaviest(a, b, ans[5]);
ans[1] = a + b - ans[0];
reverse(ans, ans + maxN);
answer(ans);
return ;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |