結果

問題 No.698 ペアでチームを作ろう
ユーザー shizushizu
提出日時 2023-09-07 20:37:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,297 bytes
コンパイル時間 3,090 ms
コンパイル使用メモリ 246,624 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-07 20:38:06
合計ジャッジ時間 3,930 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using T = tuple<int,int,bool>;
using Graph = vector<vector<int>>;

#define pb push_back
#define F first
#define S second
#define rep(i,a) for(int i = 0; i < a; ++i)
#define rrep(i, a, b) for(int i = a; i < b; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(x, y) make_pair(x,y)

template<typename T> bool chmax(T &a,T b){if(a<b){a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b; return true;} return false;}
const int INF = 1<<30;
const ll LINF = 1LL<<60;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];

    vector<ll> dp(1<<n,0);
    dp[0] = 0;
    
    for(int bit = 0; bit < (1<<n); ++bit) {
        for(int i = 0; i < n; ++i){
            if((1<<i) & bit) continue;
            for(int j = i+1; j < n; ++j){
                if((1<<j) & bit) continue;
                if(i==j) continue;
                int index = bit | (1<<i) | (1<<j);
                ll power = a[i] ^ a[j];
                chmax(dp[index],dp[bit] + power);
            }
        }
    }

    cout << dp[(1<<n) - 1] << endl;
}
0