結果

問題 No.699 ペアでチームを作ろう2
ユーザー tnakao0123tnakao0123
提出日時 2018-06-18 18:57:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 1,083 bytes
コンパイル時間 929 ms
コンパイル使用メモリ 81,484 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 06:50:42
合計ジャッジ時間 1,517 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 699.cc: No.699 ペアでチームを作ろう2 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 14;
const int NBITS = 1 << MAX_N;

/* typedef */

/* global variables */

int as[MAX_N];
int maxd = 0;

/* subroutines */

void rec(int i, int n, int bits, int d) {
  int bi = 1 << i;
  while (i < n && (bits & bi)) i++, bi <<= 1;
  if (i >= n) {
    if (maxd < d) maxd = d;
    return;
  }

  for (int j = i + 1, bj = 1 << (i + 1); j < n; j++, bj <<= 1)
    if (! (bits & bj))
      rec(i + 1, n, bits | bi | bj, d ^ (as[i] + as[j]));
}

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &as[i]);
  int nbits = 1 << n;

  rec(0, n, 0, 0);
  printf("%d\n", maxd);
  return 0;
}
0