結果

問題 No.698 ペアでチームを作ろう
ユーザー ama_nukoama_nuko
提出日時 2018-06-25 00:35:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,122 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 95,492 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-13 13:49:54
合計ジャッジ時間 1,826 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

int n;
vector<int> ans;

void solve(int s, int pow){
    if(s == (1 << n) - 1){
        ans.push_back(pow);
        return;
    }

    rep(j, n){

    }
}

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

    vector<int> dp(1 << n);
    dp[0] = 0;
    rep(s, (1 << n)){
        vector<int> x;

        rep(i, n){
            if((s >> i) % 2 == 1){
                x.push_back(i);
            }
        }
        if(x.size() % 2 == 1){
            continue;
        }

        rep(i, (int)x.size()){
            for(int j = i+1; j < (int)x.size(); j++){
                int ss = s ^ (1 << x[i]) ^ (1 << x[j]);

                dp[s] = max(dp[s], dp[ss] + (a[x[i]] ^ a[x[j]]));
            }
        }
    }
    cout << dp[(1 << n) - 1] << endl;

    return 0;
}
0