結果

問題 No.699 ペアでチームを作ろう2
ユーザー simansiman
提出日時 2021-10-17 17:49:13
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 842 bytes
コンパイル時間 4,201 ms
コンパイル使用メモリ 131,328 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 22:30:41
合計ジャッジ時間 7,691 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int N;
vector<ll> A;

int dfs(int mask, int val) {
  if (__builtin_popcount(mask) == N) {
    return val;
  }
  int value = 0;

  for (int i = 0; i < N; ++i) {
    if (mask >> i & 1) continue;

    for (int j = i + 1; j < N; ++j) {
      if (mask >> j & 1) continue;

      int nmask = mask | (1 << i) | (1 << j);
      int n_val = val ^ (A[i] + A[j]);
      int v = dfs(nmask, n_val);
      value = max(value, v);
    }
  }

  return value;
}

int main() {
  cin >> N;

  for (int i = 0; i < N; ++i) {
    ll a;
    cin >> a;
    A.push_back(a);
  }

  cout << dfs(0, 0) << endl;

  return 0;
}
0