結果
問題 |
No.698 ペアでチームを作ろう
|
ユーザー |
|
提出日時 | 2020-11-07 22:33:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 1,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 895 ms |
コンパイル使用メモリ | 86,800 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-22 14:53:32 |
合計ジャッジ時間 | 1,686 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <algorithm> #include <cmath> #include <cstdio> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; #define MOD 1000000007 int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<ll> dp(1 << n); for (int s = 0; s < (1 << n); ++s) { for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (!((1 << i) & s) && !((1 << j) & s)) { int t = s | (1 << i) | (1 << j); dp[t] = max(dp[t], dp[s] + (a[i] ^ a[j])); } } } } cout << dp[(1 << n) - 1] << endl; return 0; }