結果
| 問題 |
No.699 ペアでチームを作ろう2
|
| ユーザー |
|
| 提出日時 | 2021-07-11 01:52:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 798 bytes |
| コンパイル時間 | 2,200 ms |
| コンパイル使用メモリ | 168,268 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-02 02:57:06 |
| 合計ジャッジ時間 | 2,489 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr char newl = '\n';
void solve(int cur, int mask, ll score, const vector<ll>& a, ll& ans) {
if (cur == a.size()) {
ans = max(ans, score);
return;
}
if (mask >> cur & 1) {
solve(cur + 1, mask, score, a, ans);
return;
}
mask |= (1 << cur);
for (int i = cur; i < a.size(); i++) {
if (mask >> i & 1) continue;
solve(cur + 1, (mask | (1 << i)), score ^ (a[cur] + a[i]), a, ans);
}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
ll ans = 0;
solve(0, 0, 0, a, ans);
cout << ans << newl;
return 0;
}