結果

問題 No.519 アイドルユニット
ユーザー beetbeet
提出日時 2019-03-02 23:06:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 1,964 ms
コンパイル使用メモリ 200,248 KB
実行使用メモリ 134,464 KB
最終ジャッジ日時 2023-09-05 17:34:44
合計ジャッジ時間 8,543 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  Int f[30][30];
  for(Int i=0;i<n;i++)
    for(Int j=0;j<n;j++)
      cin>>f[i][j];

  Int s=1<<n;
  const Int INF = 1e9;
  vector<Int> dp(s,-INF);
  dp[0]=0;
  for(Int b=0;b<s;b++){
    if(__builtin_popcount(b)+2>12) continue;
    Int u=0;
    for(Int i=0;i<n;i++)
      if((~b>>i)&1) u=i;
    for(Int i=0;i<u;i++)
      if((~b>>i)&1) chmax(dp[b|(1<<i)|(1<<u)],dp[b]+f[u][i]);
  }

  int ans=0;
  for(int b=0;b<s;b++)
    chmax(ans,dp[b]+dp[(s-1)^b]);  
  cout<<ans<<endl;
  return 0;
}
0