結果

問題 No.699 ペアでチームを作ろう2
ユーザー firiexpfiriexp
提出日時 2019-08-26 19:17:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 1,129 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 101,152 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 15:44:51
合計ジャッジ時間 1,787 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <limits>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;



void solve(int val, int x, vector<int> &state){

}
int main() {
    int n;
    cin >> n;
    vector<int> v(n), ans;
    for (auto &&i : v) scanf("%d", &i);
    vector<int> state(n);
    auto rec = [&](auto &&f, int val, int cur, vector<int> &state) -> void {
        while(cur < n && state[cur] == 1) cur++;
        if(cur == n) {
            ans.emplace_back(val);
            return;
        }

        state[cur] = 1;
        for (int i = cur+1; i < n; ++i) {
            if(state[i]) continue;
            state[i] = 1;
            f(f, val^(v[cur]+v[i]), cur+1+(i == cur+1), state);
            state[i] = 0;
        }
        state[cur] = 0;
    };
    rec(rec, 0, 0, state);
    cout << *max_element(ans.begin(),ans.end()) << "\n";
    return 0;
}
0