結果

問題 No.519 アイドルユニット
ユーザー yukudoyukudo
提出日時 2017-05-28 23:39:26
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 893 ms / 1,000 ms
コード長 781 bytes
コンパイル時間 1,278 ms
コンパイル使用メモリ 159,736 KB
実行使用メモリ 69,044 KB
最終ジャッジ日時 2024-04-14 06:36:36
合計ジャッジ時間 9,358 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 751 ms
68,932 KB
testcase_01 AC 865 ms
68,864 KB
testcase_02 AC 209 ms
68,876 KB
testcase_03 AC 32 ms
68,952 KB
testcase_04 AC 19 ms
68,848 KB
testcase_05 AC 20 ms
68,936 KB
testcase_06 AC 20 ms
68,940 KB
testcase_07 AC 20 ms
69,020 KB
testcase_08 AC 20 ms
68,912 KB
testcase_09 AC 20 ms
68,848 KB
testcase_10 AC 22 ms
68,832 KB
testcase_11 AC 31 ms
68,872 KB
testcase_12 AC 20 ms
68,888 KB
testcase_13 AC 30 ms
68,944 KB
testcase_14 AC 30 ms
68,820 KB
testcase_15 AC 30 ms
68,896 KB
testcase_16 AC 31 ms
69,016 KB
testcase_17 AC 31 ms
69,044 KB
testcase_18 AC 30 ms
69,040 KB
testcase_19 AC 30 ms
68,740 KB
testcase_20 AC 31 ms
68,880 KB
testcase_21 AC 31 ms
68,896 KB
testcase_22 AC 30 ms
68,896 KB
testcase_23 AC 30 ms
68,732 KB
testcase_24 AC 65 ms
68,840 KB
testcase_25 AC 66 ms
68,884 KB
testcase_26 AC 65 ms
69,012 KB
testcase_27 AC 66 ms
68,920 KB
testcase_28 AC 66 ms
68,848 KB
testcase_29 AC 851 ms
68,940 KB
testcase_30 AC 859 ms
68,960 KB
testcase_31 AC 853 ms
68,956 KB
testcase_32 AC 893 ms
68,832 KB
testcase_33 AC 19 ms
68,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chkmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chkmax(T &a, T b) { return a < b ? (a = b, true) : false; }

typedef long long ll;

int dp[1 << 24];
int F[24][24];

int main2() {
  memset(dp, 0, sizeof(dp));
  int N; cin >> N;
  REP(i, N) REP(j, N) cin >> F[i][j];

  REP(set, 1 << N) {
    if(__builtin_parity(set)) continue;
    int a = __builtin_ffs(~set) - 1;
    for (int j = a + 1; j < N; j++) if ((set >> j & 1) == 0) {
      chkmax(dp[set | (1 << a) | (1 << j)], dp[set] + F[a][j]);
    }
  }

  cout << dp[ (1 << N) - 1 ] << endl;

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}
0