結果

問題 No.699 ペアでチームを作ろう2
ユーザー face4face4
提出日時 2018-09-04 13:39:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 552 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 64,900 KB
実行使用メモリ 10,272 KB
最終ジャッジ日時 2024-04-21 09:48:37
合計ジャッジ時間 3,915 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
using namespace std;

int n, ans = 0, a[14] = {};

void dfs(int score, int bitset){
    if(bitset == (1<<n)-1){
        ans = max(ans, score);
        return;
    }

    for(int i = 0; i < n; i++){
        if(~bitset & 1<<i){
            for(int j = i+1; j < n; j++){
                if(~bitset & 1<<j){
                    dfs(score ^ (a[i] + a[j]), bitset|1<<i|1<<j);
                }
            }
        }
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> a[i];
    dfs(0, 0);
    cout << ans << endl;
}
0