# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
552002 | Theo830 | Scales (IOI15_scales) | C++17 | 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9+7;
const ll MOD = 998244353;
typedef pair<ll,ll> ii;
#define iii pair<ll,ii>
#define f(i,a,b) for(ll i = a;i < b;i++)
#define pb push_back
#define vll vector<ll>
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
///I hope I will get uprating and don't make mistakes
///I will never stop programming
///sqrt(-1) Love C++
///Please don't hack me
///@TheofanisOrfanou Theo830
///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst)
///Stay Calm
///Look for special cases
///Beware of overflow and array bounds
///Think the problem backwards
///Training
#include "scales.h"
void init(int T) {
}
void orderCoins() {
int W[] = {1, 2, 3, 4, 5, 6};
vector<int>ex[2];
ex[0].pb(getHeaviest(1,2,3));
set<ll>e;
f(i,0,3){
e.insert(i+1);
}
e.erase(ex[0].back());
for(auto x:e){
ex[0].insert(ex[0].begin(),x);
}
ex[1].pb(getHeaviest(4,5,6));
e.clear();
f(i,3,6){
e.insert(i+1);
}
e.erase(ex[1].back());
for(auto x:e){
ex[1].insert(ex[1].begin(),x);
}
W[5] = getHeaviest(ex[1].back(),ex[0].back(),ex[1][1]);
if(W[5] != ex[1].back()){
swap(ex[0],ex[1]);
}
if(ex[0][1] != getMedian(ex[0][0],ex[0][1],ex[0][2])){
swap(ex[0][0],ex[0][1]);
}
ll p = getNextLightest(ex[1][0],ex[1][1],ex[1][2],ex[0][1]);
if(p == ex[1][2]){
W[4] = ex[0][2];
W[3] = ex[0][1];
W[0] = getLightest(ex[0][0],ex[1][1],ex[1][0]);
W[1] = getMedian(ex[0][0],ex[1][1],ex[1][0]);
W[2] = ex[0][0] + ex[1][1] + ex[1][0] - W[0] - W[1];
}
else{
ll o = ex[1][0] + ex[1][1] - p;
ll p2 = getNextLightest(ex[0][0],ex[0][1],W[5],o);
if(p2 == ex[0][0]){
W[0] = o;
W[1] = ex[0][0];
W[2] = ex[0][1];
W[3] = getLightest(ex[0][2],p,W[5]);
W[4] = ex[0][2] + p - W[3];
}
else if(p2 == ex[0][1]){
W[0] = ex[0][0];
W[1] = o;
W[2] = ex[0][1];
W[3] = getLightest(ex[0][2],p,W[5]);
W[4] = ex[0][2] + p - W[3];
}
else{
W[0] = ex[0][0];
W[1] = ex[0][1];
W[3] = getMedian(ex[0][2],o,p);
if(W[3] == p){
W[4] = o;
W[2] = ex[0][2];
}
else if(W[3] == o){
W[2] = p;
W[4] = ex[0][2];
}
else{
W[2] = p;
W[4] = o;
}
}
}
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |