結果
| 問題 |
No.699 ペアでチームを作ろう2
|
| ユーザー |
|
| 提出日時 | 2018-10-21 00:55:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 182 ms / 1,000 ms |
| コード長 | 625 bytes |
| コンパイル時間 | 2,184 ms |
| コンパイル使用メモリ | 203,052 KB |
| 最終ジャッジ日時 | 2025-01-06 14:44:27 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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];
function<set<int>(int)> search = [&](int s) {
if (s + 1 == 1 << N) return set<int>({0});
int l = __builtin_ctz(~s);
set<int> res;
for (int i = 0; i < N; ++i) {
if (~s >> i & 1) {
if (i != l) {
auto v = search(s | 1 << i | 1 << l);
for (auto u : v) res.emplace(A[i] + A[l] ^ u);
}
}
}
return res;
};
auto v = search(0);
cout << *v.rbegin() << endl;
return 0;
}