結果
| 問題 |
No.519 アイドルユニット
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-03-17 19:13:49 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 991 ms / 1,000 ms |
| コード長 | 608 bytes |
| コンパイル時間 | 1,667 ms |
| コンパイル使用メモリ | 160,740 KB |
| 実行使用メモリ | 134,528 KB |
| 最終ジャッジ日時 | 2025-03-17 19:14:16 |
| 合計ジャッジ時間 | 10,277 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, a[25][25], dp[1 << 24], tong[25], cnt;
signed main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 0; i < n; i ++ )
for (int j = 0; j < n; j ++ )
cin >> a[i][j];
for (int i = 3; i < (1 << n); i ++ )
{
if (__builtin_popcount(i) & 1) continue;
int cnt = 0;
for (int j = 0; j < n; j ++ )
if (i >> j & 1) tong[ ++ cnt] = j;
for (int j = 2; j <= cnt; j ++ )
dp[i] = max(dp[i - (1 << tong[1]) - (1 << tong[j])] + a[tong[1]][tong[j]], dp[i]);
}
cout << dp[(1 << n) - 1];
return 0;
}
vjudge1