結果

問題 No.698 ペアでチームを作ろう
ユーザー rpy3cpprpy3cpp
提出日時 2018-08-12 22:27:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 718 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 169,148 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2023-10-24 16:24:39
合計ジャッジ時間 4,679 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,840 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 10 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 535 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 <bits/stdc++.h>
using namespace std;


int dfs(int used, int n_rem, int score, const vector<int>& As){
    if (n_rem == 0) return score;
    int record = score;
    for (int i = 0; i < As.size() - 1; ++i){
        if (used & (1 << i)) continue;
        for (int j = i + 1; j < As.size(); ++j){
            if (used & (1 << j)) continue;
            int new_used = used | (1 << i) | (1 << j);
            int new_score = score + (As[i] ^ As[j]);
            record = max(record, dfs(new_used, n_rem - 2, new_score, As));
        }
    }
    return record;
}


int main() {
    int N;
    cin >> N;
    vector<int> As(N);
    for (auto & a : As) cin >> a;

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

    return 0;
}
0