結果

問題 No.519 アイドルユニット
ユーザー simansiman
提出日時 2022-03-04 18:26:07
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 990 bytes
コンパイル時間 6,328 ms
コンパイル使用メモリ 104,896 KB
実行使用メモリ 69,084 KB
最終ジャッジ日時 2023-09-25 19:36:26
合計ジャッジ時間 18,976 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 346 ms
69,004 KB
testcase_03 AC 36 ms
69,004 KB
testcase_04 AC 19 ms
68,952 KB
testcase_05 AC 19 ms
69,064 KB
testcase_06 AC 20 ms
69,008 KB
testcase_07 AC 19 ms
68,956 KB
testcase_08 AC 20 ms
69,072 KB
testcase_09 AC 21 ms
69,028 KB
testcase_10 AC 24 ms
69,080 KB
testcase_11 AC 36 ms
69,028 KB
testcase_12 AC 20 ms
68,964 KB
testcase_13 AC 35 ms
68,932 KB
testcase_14 AC 36 ms
69,004 KB
testcase_15 AC 36 ms
68,956 KB
testcase_16 AC 36 ms
69,048 KB
testcase_17 AC 35 ms
68,960 KB
testcase_18 AC 36 ms
69,020 KB
testcase_19 AC 36 ms
68,932 KB
testcase_20 AC 36 ms
68,944 KB
testcase_21 AC 36 ms
69,004 KB
testcase_22 AC 36 ms
69,036 KB
testcase_23 AC 36 ms
68,996 KB
testcase_24 AC 93 ms
68,960 KB
testcase_25 AC 93 ms
68,968 KB
testcase_26 AC 93 ms
68,960 KB
testcase_27 AC 94 ms
69,020 KB
testcase_28 AC 94 ms
69,084 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 19 ms
68,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>

using namespace std;
typedef long long ll;

int dp[1 << 24];

int main() {
  int N;
  cin >> N;
  int V[N][N];

  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> V[i][j];
    }
  }

  int L = 1 << N;
  memset(dp, 0, sizeof(dp));
  int ans = 0;

  for (int i = 0; i < N / 2; ++i) {
    for (int mask = 0; mask < L; ++mask) {
      if (__builtin_popcount(mask) != 2 * i) continue;

      for (int j = 0; j < N; ++j) {
        if (mask >> j & 1) continue;
        for (int k = j + 1; k < N; ++k) {
          if (mask >> k & 1) continue;
          int nmask = mask | (1 << j) | (1 << k);
          dp[nmask] = max(dp[nmask], dp[mask] + V[j][k]);
          ans = max(ans, dp[nmask]);
        }
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}
0