# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
42215 | MatheusLealV | Scales (IOI15_scales) | C++14 | 2 ms | 800 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>
#include "scales.h"
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
int n = 6, v[10], ord[10];
int sobra(int a, int b, int c, int x, int y)
{
if(x == a && y == b) return c;
if(y == a && x == b) return c;
if(x == a && y == c) return b;
if(y == a && x == c) return b;
if(x == b && y == c) return a;
if(y == b && x == c) return a;
}
void orderCoins()
{
int ans[6], a[4], b[4];
a[1] = getLightest(1, 2, 3), a[2] = getMedian(1, 2, 3), a[3] = sobra(1, 2, 3, a[1], a[2]);
b[1] = getLightest(4, 5, 6), b[2] = getMedian(4, 5, 6), b[3] = sobra(4, 5, 6, b[1], b[2]);
int pl = 1, pr = 1;
for(int i = 0; i < 6; i++)
{
if(!i)
{
ans[0] = getLightest(a[1], b[1], a[2]);
if(ans[0] == a[1]) pl ++;
else pr ++;
}
else
{
if(pl <= 3 && pr <= 3)
{
ans[i] = getMedian(ans[0], a[pl], b[pr]);
if(ans[i] == a[pl]) pl ++;
else pr ++;
}
else if(pl > 3) ans[i] = b[pr], pr ++;
else ans[i] = a[pl], pl ++;
}
}
answer(ans);
}
void init(int T)
{
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |