# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1009804 | hotboy2703 | Scales (IOI15_scales) | C++14 | 42 ms | 600 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;
using ll = int;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
void init(int T) {
/* ... */
}
vector<vector<ll> > all;
ll w[7];
void orderCoins() {
{
vector <ll> p(6);
iota(p.begin(),p.end(),1);
do{
all.push_back(p);
}while (next_permutation(p.begin(),p.end()));
}
while (sz(all) > 1){
ll type;
vector <ll> a;
ll worst = 1e9;
for (ll i = 1;i <= 6;i ++){
for (ll j = i + 1;j <= 6;j ++){
for (ll k = j + 1;k <= 6;k ++){
{
ll cnt[3] = {};
for (auto p:all){
for (ll j = 0;j < 6;j ++)w[p[j]] = j;
ll min_w = min({w[i],w[j],w[k]});
if (w[i] == min_w)cnt[0]++;
if (w[j] == min_w)cnt[1]++;
if (w[k] == min_w)cnt[2]++;
}
if (worst > max({cnt[0],cnt[1],cnt[2]})){
worst = max({cnt[0],cnt[1],cnt[2]});
a = {i,j,k};
type = 0;
}
}
{
ll cnt[3] = {};
for (auto p:all){
for (ll j = 0;j < 6;j ++)w[p[j]] = j;
ll max_w = max({w[i],w[j],w[k]});
if (w[i] == max_w)cnt[0]++;
if (w[j] == max_w)cnt[1]++;
if (w[k] == max_w)cnt[2]++;
}
if (worst > max({cnt[0],cnt[1],cnt[2]})){
worst = max({cnt[0],cnt[1],cnt[2]});
a = {i,j,k};
type = 1;
}
}
{
ll cnt[3] = {};
for (auto p:all){
for (ll j = 0;j < 6;j ++)w[p[j]] = j;
ll med_w = w[i] + w[j] + w[k] - min({w[i],w[j],w[k]}) - max({w[i],w[j],w[k]});
if (w[i] == med_w)cnt[0]++;
if (w[j] == med_w)cnt[1]++;
if (w[k] == med_w)cnt[2]++;
}
if (worst > max({cnt[0],cnt[1],cnt[2]})){
worst = max({cnt[0],cnt[1],cnt[2]});
a = {i,j,k};
type = 2;
}
}
}
}
}
ll res;
vector <vector <ll> > tmp;
if (type==0){
res = getLightest(a[0],a[1],a[2]);
for (auto p:all){
for (ll j = 0;j < 6;j ++)w[p[j]] = j;
ll min_w = min({w[a[0]],w[a[1]],w[a[2]]});
if (w[res] == min_w)tmp.push_back(p);
}
}
if (type==1){
res = getHeaviest(a[0],a[1],a[2]);
for (auto p:all){
for (ll j = 0;j < 6;j ++)w[p[j]] = j;
ll max_w = max({w[a[0]],w[a[1]],w[a[2]]});
if (w[res] == max_w)tmp.push_back(p);
}
}
if (type==2){
res = getMedian(a[0],a[1],a[2]);
for (auto p:all){
for (ll j = 0;j < 6;j ++)w[p[j]] = j;
ll med_w = w[a[0]] + w[a[1]] + w[a[2]] - min({w[a[0]],w[a[1]],w[a[2]]}) - max({w[a[0]],w[a[1]],w[a[2]]});
if (w[res] == med_w)tmp.push_back(p);
}
}
all = tmp;
}
/* ... */
ll W[6];
for (ll j = 0;j < 6;j ++)W[j] = all[0][j];
answer(W);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |