# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
287329 | Saboon | Scales (IOI15_scales) | C++17 | 1 ms | 384 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;
int RET[6];
void init(int T){
/* ... */
}
vector<int> solve(vector<int> A){
vector<int> P(4);
int v = A[0], u = A[1], w = A[2], z = A[3];
int x = getMedian(v,u,w);
if (u == x) swap(u,v);
if (w == x) swap(w,v);
int y = getNextLightest(u,w,z,v);
if (y == z){
int p = getLightest(v,u,w);
P[0] = p, P[1] = v, P[2] = z, P[3] = (w^u^p);
return P;
}
if (y == w) swap(w,u);
int t = getMedian(z,w,v);
if (t == w)
P[0] = z, P[1] = w, P[2] = v, P[3] = u;
else if (t == z)
P[0] = w, P[1] = z, P[2] = v, P[3] = u;
else
P[0] = w, P[1] = v, P[2] = u, P[3] = z;
return P;
}
void orderCoins() {
vector<int> A(4), P(4);
for (int i = 1; i <= 4; i++)
A[i-1] = i;
P = solve(A);
int v = 5;
int w = getNextLightest(P[0], P[1], P[2], v);
if (w == P[1])
P.insert(P.begin()+1, v);
else if (w == P[2])
P.insert(P.begin()+2, v);
else{
int z = getMedian(P[2], v, P[3]);
if (z == P[2])
P.insert(P.begin()+0, v);
else if (z == v)
P.insert(P.begin()+3, v);
else
P.insert(P.begin()+4, v);
}
v = 6;
w = getMedian(P[1], P[3], v);
if (w == P[1]){
if (getLightest(P[0], P[1], v) == v)
P.insert(P.begin()+0, v);
else
P.insert(P.begin()+1, v);
}
else if (w == v){
if (getLightest(P[2], P[3], v) == v)
P.insert(P.begin()+2, v);
else
P.insert(P.begin()+3, v);
}
else{
if (getHeaviest(P[3], P[4], v) == P[4])
P.insert(P.begin()+4, v);
else
P.insert(P.begin()+5, v);
}
for (int i = 0; i < 6; i++)
RET[i] = P[i];
answer(RET);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |