제출 #1009807

#제출 시각아이디문제언어결과실행 시간메모리
1009807hotboy2703저울 (IOI15_scales)C++14
71.43 / 100
53 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() { all.clear(); { 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; } } for (ll d=k+1;d<=6;d++){ { ll cnt[3] = {}; for (auto p:all){ for (ll j = 0;j < 6;j ++)w[p[j]] = j; ll cw = 100; for (auto x:vector <ll> ({i,j,k})){ if (w[x] > w[d] && w[x] < cw)cw = w[x]; } if (cw == 100)cw = min({w[i],w[j],w[k]}); if (w[i] == cw)cnt[0]++; if (w[j] == cw)cnt[1]++; if (w[k] == cw)cnt[2]++; } if (worst > max({cnt[0],cnt[1],cnt[2]})){ worst = max({cnt[0],cnt[1],cnt[2]}); a = {i,j,k,d}; type = 3; } } } } } } 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); } } if (type==3){ res = getNextLightest(a[0],a[1],a[2],a[3]); for (auto p:all){ for (ll j = 0;j < 6;j ++)w[p[j]] = j; ll cw = 100; for (auto x:vector <ll> ({a[0],a[1],a[2]})){ if (w[x] > w[a[3]] && w[x] < cw)cw = w[x]; } if (cw == 100)cw = min({w[a[0]],w[a[1]],w[a[2]]}); if (w[res] == cw)tmp.push_back(p); } } all = tmp; } /* ... */ ll W[6]; for (ll j = 0;j < 6;j ++)W[j] = all[0][j]; answer(W); }

컴파일 시 표준 에러 (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:36:37: warning: declaration of 'j' shadows a previous local [-Wshadow]
   36 |                             for (ll j = 0;j < 6;j ++)w[p[j]] = j;
      |                                     ^
scales.cpp:31:21: note: shadowed declaration is here
   31 |             for (ll j = i + 1;j <= 6;j ++){
      |                     ^
scales.cpp:52:37: warning: declaration of 'j' shadows a previous local [-Wshadow]
   52 |                             for (ll j = 0;j < 6;j ++)w[p[j]] = j;
      |                                     ^
scales.cpp:31:21: note: shadowed declaration is here
   31 |             for (ll j = i + 1;j <= 6;j ++){
      |                     ^
scales.cpp:68:37: warning: declaration of 'j' shadows a previous local [-Wshadow]
   68 |                             for (ll j = 0;j < 6;j ++)w[p[j]] = j;
      |                                     ^
scales.cpp:31:21: note: shadowed declaration is here
   31 |             for (ll j = i + 1;j <= 6;j ++){
      |                     ^
scales.cpp:84:41: warning: declaration of 'j' shadows a previous local [-Wshadow]
   84 |                                 for (ll j = 0;j < 6;j ++)w[p[j]] = j;
      |                                         ^
scales.cpp:31:21: note: shadowed declaration is here
   31 |             for (ll j = i + 1;j <= 6;j ++){
      |                     ^
scales.cpp:130:9: warning: 'type' may be used uninitialized in this function [-Wmaybe-uninitialized]
  130 |         if (type==3){
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...