結果
| 問題 |
No.519 アイドルユニット
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2022-03-04 18:37:40 |
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 868 ms / 1,000 ms |
| コード長 | 914 bytes |
| コンパイル時間 | 1,272 ms |
| コンパイル使用メモリ | 140,792 KB |
| 実行使用メモリ | 68,992 KB |
| 最終ジャッジ日時 | 2024-07-18 15:40:30 |
| 合計ジャッジ時間 | 10,607 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
ソースコード
#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 mask = 0; mask < L; ++mask) {
ans = max(ans, dp[mask]);
if (__builtin_popcount(mask) & 1) 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]);
}
break;
}
}
cout << ans << endl;
return 0;
}
siman