結果

問題 No.698 ペアでチームを作ろう
ユーザー le_panda_noirle_panda_noir
提出日時 2020-06-14 11:45:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 832 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 71,128 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 10:42:09
合計ジャッジ時間 1,520 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 9 ms
4,384 KB
testcase_06 AC 9 ms
4,380 KB
testcase_07 AC 9 ms
4,380 KB
testcase_08 AC 9 ms
4,380 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 9 ms
4,376 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 9 ms
4,376 KB
testcase_14 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define _overload3(_1,_2,_3,name,...) name
#define _rrep2(i,n) for(long long i=(n);i>=0;--i)
#define _rrep3(i,b,a) for(long long i=(b);i>=a;--i)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)

constexpr int INF = 1e9;
int N;
constexpr int MAX_N = 14;
constexpr int POW_N = 1 << MAX_N;
int dp[POW_N], A[MAX_N];
int main() {
  cin >> N;
  rep(i, N)
    cin >> A[i];

  rep(i, 1<<N) dp[i] = 0;
  rrep(bit, (1 << N)-1) {
    rep(i, N) {
      if (bit & (1 << i))
        continue;
      rep(j, N) {
        if (bit & (1 << j))
          continue;
        dp[bit] = max(dp[bit], dp[bit | (1 << i) | (1 << j)] + (A[i] ^ A[j]));
      }
    }
  }
  cout << dp[0] << endl;

  return 0;
}
0