結果

問題 No.519 アイドルユニット
ユーザー beetbeet
提出日時 2019-03-02 23:05:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 766 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 200,644 KB
実行使用メモリ 134,516 KB
最終ジャッジ日時 2023-09-05 17:34:33
合計ジャッジ時間 13,222 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1 ms
4,376 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 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
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)>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<n;b++)
    chmax(ans,dp[b]+dp[(s-1)^b]);  
  cout<<ans<<endl;
  return 0;
}
0