# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604403 | wiwiho | Scales (IOI15_scales) | C++14 | 1 ms | 340 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 iter(a) a.begin(), a.end()
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
#define eb emplace_back
#define ef emplace_front
#define pob pop_back()
#define pof pop_front()
#define mp make_pair
#define F first
#define S second
#define uni(a) a.resize(unique(iter(a)) - a.begin())
#define printv(a, b){ \
for(auto pv : a) b << pv << " "; \
b << "\n"; \
}
using namespace std;
typedef long long ll;
typedef long double ld;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename A, typename B>
ostream& operator<<(ostream& o, pair<A, B> p){
return o << '(' << p.F << ',' << p.S << ')';
}
void init(int T){
}
vector<int> solve(){
vector<int> A, B;
{
int l = getLightest(1, 2, 3);
int r = getHeaviest(1, 2, 3);
A.eb(l);
A.eb(l ^ r ^ 1 ^ 2 ^ 3);
A.eb(r);
}
{
int l = getLightest(4, 5, 6);
int r = getHeaviest(4, 5, 6);
B.eb(l);
B.eb(l ^ r ^ 4 ^ 5 ^ 6);
B.eb(r);
}
int tmp = getMedian(A[1], A[2], B[2]);
if(tmp == A[2]){
// A[0] A[1] A[2] B[2]
tmp = getMedian(A[1], A[2], B[1]);
if(tmp == A[2]){
// A[0] A[1] A[2] B[1] B[2]
tmp = getMedian(A[0], A[1], B[0]);
if(tmp == A[0]) return {B[0], A[0], A[1], A[2], B[1], B[2]};
else if(tmp == B[0]) return {A[0], B[0], A[1], A[2], B[1], B[2]};
else{
tmp = getMedian(A[1], B[0], A[2]);
if(tmp == B[0]) return {A[0], A[1], B[0], A[2], B[1], B[2]};
else return {A[0], A[1], A[2], B[0], B[1], B[2]};
}
}
else if(tmp == B[1]){
// A[0] A[1] B[1] A[2] B[2]
tmp = getMedian(A[0], A[1], B[0]);
if(tmp == A[1]) return {A[0], A[1], B[0], B[1], A[2], B[2]};
else if(tmp == B[0]) return {A[0], B[0], A[1], B[1], A[2], B[2]};
else return {B[0], A[0], A[1], B[1], A[2], B[2]};
}
else{
// A[0] B[1] A[1] A[2] B[2]
tmp = getMedian(A[0], B[0], B[1]);
if(tmp == B[0]) return {A[0], B[0], B[1], A[1], A[2], B[2]};
else return {B[0], A[0], B[1], A[1], A[2], B[2]};
}
}
else if(tmp == B[2]){
// A[0] A[1] B[2] A[2]
tmp = getMedian(A[0], A[1], B[1]);
if(tmp == A[1]){
// A[0] A[1] B[1] B[2] A[2]
tmp = getMedian(A[0], A[1], B[0]);
if(tmp == A[1]) return {A[0], A[1], B[0], B[1], B[2], A[2]};
else if(tmp == B[0]) return {A[0], B[0], A[1], B[1], B[2], A[2]};
else return {B[0], A[0], A[1], B[1], B[2], A[2]};
}
else if(tmp == B[1]){
// A[0] B[1] A[1] B[2] A[2]
tmp = getMedian(B[0], A[0], B[1]);
if(tmp == A[0]) return {B[0], A[0], B[1], A[1], B[2], A[2]};
else return {A[0], B[0], B[1], A[1], B[2], A[2]};
}
}
else{
// B[0] B[1] B[2] A[1] A[2]
tmp = getMedian(B[0], B[1], A[0]);
if(tmp == B[0]) return {A[0], B[0], B[1], B[2], A[1], A[2]};
else if(tmp == A[0]) return {B[0], A[0], B[1], B[2], A[1], A[2]};
else return {B[0], B[1], A[0], B[2], A[1], A[2]};
}
}
void orderCoins(){
vector<int> ans = solve();
int av[6];
for(int i = 0; i < 6; i++) av[i] = ans[i];
answer(av);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |