Submission #1009804

#TimeUsernameProblemLanguageResultExecution timeMemory
1009804hotboy2703Scales (IOI15_scales)C++14
71.73 / 100
42 ms600 KiB
#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)

scales.cpp: In function 'void init(int)':
scales.cpp:12:15: warning: unused parameter 'T' [-Wunused-parameter]
   12 | void init(int T) {
      |           ~~~~^
scales.cpp: In function 'void orderCoins()':
scales.cpp:35:37: warning: declaration of 'j' shadows a previous local [-Wshadow]
   35 |                             for (ll j = 0;j < 6;j ++)w[p[j]] = j;
      |                                     ^
scales.cpp:30:21: note: shadowed declaration is here
   30 |             for (ll j = i + 1;j <= 6;j ++){
      |                     ^
scales.cpp:51:37: warning: declaration of 'j' shadows a previous local [-Wshadow]
   51 |                             for (ll j = 0;j < 6;j ++)w[p[j]] = j;
      |                                     ^
scales.cpp:30:21: note: shadowed declaration is here
   30 |             for (ll j = i + 1;j <= 6;j ++){
      |                     ^
scales.cpp:67:37: warning: declaration of 'j' shadows a previous local [-Wshadow]
   67 |                             for (ll j = 0;j < 6;j ++)w[p[j]] = j;
      |                                     ^
scales.cpp:30:21: note: shadowed declaration is here
   30 |             for (ll j = i + 1;j <= 6;j ++){
      |                     ^
scales.cpp:100:9: warning: 'type' may be used uninitialized in this function [-Wmaybe-uninitialized]
  100 |         if (type==2){
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...