結果
| 問題 | No.698 ペアでチームを作ろう |
| ユーザー |
|
| 提出日時 | 2018-10-21 00:15:18 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 537 bytes |
| 記録 | |
| コンパイル時間 | 1,997 ms |
| コンパイル使用メモリ | 194,536 KB |
| 最終ジャッジ日時 | 2025-01-06 14:44:16 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; ++i) cin >> A[i];
vector<int> dp(1 << N);
for (int s = 0; s + 1 < 1 << N; ++s) {
if (__builtin_popcount(s) & 1) continue;
int l = __builtin_ctz(~s);
for (int i = 0; i < N; ++i)
if (~s >> i & 1)
if (i != l)
dp[s | 1 << l | 1 << i] = max(dp[s | 1 << l | 1 << i], dp[s] + (A[l] ^ A[i]));
}
cout << dp.back() << endl;
return 0;
}