結果

問題 No.699 ペアでチームを作ろう2
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-06-21 16:57:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 824 bytes
コンパイル時間 1,938 ms
コンパイル使用メモリ 146,700 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-13 07:34:23
合計ジャッジ時間 4,330 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define i64 long long
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
vector<i64> A;
i64 ans = 0;

int rec2(int,i64,i64);
int rec(int bit,i64 XOR){
    if(bit == (1 << N) - 1){
        ans = max(ans , XOR);
        return 0;
    }
    for(int i = 0;i < N;i++){
        if ((bit & (1 << i)))
            continue;
        rec2(bit | (1 << i),XOR,A[i]);
    }
    return 0;
}

int rec2(int bit,i64 XOR,i64 temp){
    if(bit == (1 << N) - 1){
        ans = max(ans , XOR);
        return 0;
    }
    for(int i = 0;i < N;i++){
        if ((bit & (1 << i)))
            continue;
        rec(bit | (1 << i), XOR ^ (A[i] + temp));
    }
    return 0;
}
int main(){
    cin >> N;
    A.resize(N);
    rep(i,0,N - 1) cin >> A[i];
    rec(0,0);
    cout << ans << endl;
}
0