結果
問題 | No.698 ペアでチームを作ろう |
ユーザー |
|
提出日時 | 2022-10-10 05:51:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 44 ms / 1,000 ms |
コード長 | 787 bytes |
コンパイル時間 | 1,983 ms |
コンパイル使用メモリ | 203,460 KB |
最終ジャッジ日時 | 2025-02-08 01:08:02 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector<int> A(N); rep(i,N) cin >> A[i]; int ans = -1e9, sum = 0; set<int> st; rep(i,N) st.insert(i); function<void(void)> dfs = [&](void) -> void { if(int(st.size()) == 0) { ans = max(ans, sum); } else { int L = *st.begin(); st.erase(L); set<int> R = st; for(int x : R) { sum += (A[L] ^ A[x]); st.erase(x); dfs(); sum -= (A[L] ^ A[x]); st.insert(x); } st.insert(L); } }; dfs(); cout << ans << endl; }