# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
604416 | wiwiho | Scales (IOI15_scales) | C++14 | 1 ms | 212 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 << ')';
}
mt19937 rnd(clock());
void init(int T){
}
int tt = 0;
vector<int> solve(){
tt++;
cerr << "solve " << tt << "\n";
vector<int> T = {1, 2, 3, 4, 5, 6};
shuffle(iter(T), rnd);
vector<int> A, B;
{
int l = getLightest(T[0], T[1], T[2]);
int r = getHeaviest(T[0], T[1], T[2]);
A.eb(l);
A.eb(l ^ r ^ T[0] ^ T[1] ^ T[2]);
A.eb(r);
}
{
int l = getLightest(T[3], T[4], T[5]);
int r = getHeaviest(T[3], T[4], T[5]);
B.eb(l);
B.eb(l ^ r ^ T[3] ^ T[4] ^ T[5]);
B.eb(r);
}
printv(A, cerr);
printv(B, cerr);
int tmp = getMedian(A[1], A[2], B[2]);
cerr << tmp << "\n";
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{
// 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 if(tmp == A[0]) return {B[0], A[0], B[1], A[1], A[2], B[2]};
else return {B[0], B[1], A[0], 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{
return {B[0], B[1], A[0], 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{
tmp = getMedian(A[0], B[2], A[1]);
if(tmp == B[2]) return {B[0], B[1], A[0], B[2], A[1], A[2]};
else return {B[0], B[1], B[2], A[0], 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... |