結果

問題 No.699 ペアでチームを作ろう2
ユーザー Kiona1018Kiona1018
提出日時 2019-09-25 00:19:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 659 bytes
コンパイル時間 1,880 ms
コンパイル使用メモリ 171,036 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 18:35:05
合計ジャッジ時間 3,000 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

ll search(vector<int> a, ll power)
{
    if (a.size() == 0)
        return power;
    
    ll res = 0;
    ll one = a[0];
    a.erase(a.begin());
    rep(i, 0, a.size())
    {
        vector<int> aa = a;
        aa.erase(aa.begin() + i);
        res = max(res, search(aa, power ^ (one+a[i])));
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];

    cout << search(a, 0) << endl;
    return 0;
}
0