# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
601576 | AmirElarbi | Scales (IOI15_scales) | C++14 | 1 ms | 304 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 vi vector<int>
#define gi greater<int>
#define gr greater
#define ve vector
#define ll long long
#define vf vector<float>
#define vll vector<pair<ll,ll>>
#define ii pair<int,int>
#define pll pair<ll,ll>
#define vvi vector<vi>
#define vii vector<ii>
#define gii greater<ii>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF 1e9
#define eps 1e-7
#define eps1 1e-2
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX_A 2e5+5
using namespace std;
const int MOD = 1e9+7;
const int nax = 2e5+5;
typedef complex<int> Point;
#define X real()
#define Y imag()
#include "scales.h"
using namespace std;
void init(int T) {
}
void orderCoins() {
int ans[6] = {1, 2, 3, 4, 5, 6};
int hv1 = getHeaviest(1,2,3), hv2 = getHeaviest(4,5,6),
med1 = getMedian(1,2,3), med2 = getMedian(4,5,6),
lght1 = 0, lght2 = 0;
for (int i = 1; i <= 3; ++i)
{
if(i != hv1 && i != med1) lght1 = i;
}
for (int i = 4; i <= 6; ++i)
{
if(i != hv2 && i != med2) lght2 = i;
}
int lb1 = getNextLightest(hv1, med1, lght1, lght2);
if(lb1 == lght1){
int lb2 = getNextLightest(lght2, hv1, lght1, med2);
if(lb2 == lght2) {
ans[5] = hv2, ans[4] = med2;
int lb3 = getHeaviest(hv1, med1, lght2);
if(lb3 == lght1) ans[3] = lght2, ans[2] = hv1, ans[1] = med1, ans[0] = lght1;
else ans[3] = hv1, ans[2] = med1, ans[1] = lght1, ans[0] = lght2;
} else if(lb2 == lght1) {
int lb3 = getNextLightest(hv1, med1, lght1, hv2);
if(lb3 == med1) ans[0] = lght2, ans[1] = med2, ans[2] = lght1, ans[3] = hv2, ans[4] = med1, ans[5] = hv1;
else if(lb3 == hv1) ans[0] = lght2, ans[1] = med2, ans[2] = lght1, ans[3] = med1, ans[4] = hv2, ans[5] = hv1;
else {
int lb4 = getMedian(hv1,hv2,lght2);
if(lb4 == hv2) ans[0] = lght2, ans[1] = med2,ans[2] = hv2, ans[3] = lght1, ans[4] = med1, ans[5] = hv1;
else if(lb4 == hv1) ans[0] = lght2, ans[1] = med2, ans[2] = lght1, ans[3] = med1, ans[4] = hv1, ans[5] = hv2;
else ans[0] = lght1, ans[1] = med1, ans[2] = hv1, ans[3] = lght2, ans[4] = med2, ans[5] = hv2;
}
} else {
ans[0] = lght2, ans[1] = lght1, ans[2] = med1, ans[3] = med2;
int lb3 = getHeaviest(hv1,hv2,med2);
if(lb3 == hv1) ans[4] = hv2, ans[5] = hv1;
else ans[4] = hv1, ans[5] = hv2;
}
} else {
ans[0] = lght1;
if(lb1 == hv1) {
int lb2 = getNextLightest(hv2, med2, lght2, hv1);
ans[1] = med1;
ans[2] = lght2;
if(lb2 == lght2) ans[3] = med2, ans[4] = hv2, ans[5] = hv1;
else if(lb2 == med2) ans[3] = hv1, ans[4] = med2, ans[5] = hv2;
else ans[3] = med2, ans[4] = hv1, ans[5] = hv2;
}
else{
ans[1] = lght2;
int lb2 = getNextLightest(hv2, med2, med1, hv1), lb3 = getNextLightest(hv2, med2, hv1, med1);
if(lb2 == hv2){
ans[5] = hv2, ans[4] = hv1;
if(lb3 == med2) ans[3] = med2, ans[2] = med1;
else ans[3] = med1, ans[2] = med2;
} else if(lb2 == med2){
ans[5] = hv2, ans[4] = med2, ans[3] = hv1, ans[2] = med1;
} else {
ans[5] = hv1;
if(lb3 == hv2) ans[4] = hv2, ans[3] = med1, ans[2] = med2;
else if(lb3 == hv1) ans[4] = med1, ans[3] = hv2, ans[2] = med2;
else ans[4] = hv2, ans[3] = med2, ans[2] = med1;
}
}
}
answer(ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |