結果

問題 No.698 ペアでチームを作ろう
ユーザー house_guardhouse_guard
提出日時 2024-01-04 18:05:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,123 bytes
コンパイル時間 2,512 ms
コンパイル使用メモリ 206,908 KB
実行使用メモリ 814,716 KB
最終ジャッジ日時 2024-01-04 18:05:45
合計ジャッジ時間 5,724 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
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;
using ll = long long;
#define rep(i,j,k) for(int i=j; i<(int)(k); i++)
#define rrep(i,j,k) for(int i=j; i>=(int)(k); i--)
#define Rep(i,j,k) for(ll i=j; i<(ll)(k); i++)
#define RRep(i,j,k) for(ll i=j; i>=(ll)(k); i--)
#define all(v) v.begin(), v.end()

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

    vector<vector<int>> dp(n,vector<int>(7e7+1));
    rep(i,0,n){
        rep(j,i+1,n){
            int r = (a[i] ^ a[j]);
            dp[1][r]+=(1 << (i)) + (1 << (j));
        }
    }
    for(int i=1; i<n-2; i+=2){
        rep(j,0,7e7+1){
            if(dp[i][j]!=0){
                bitset<16> r(dp[i][j]);
                rep(k,0,n){
                    rep(l,k+1,n){
                        if(r.test(k) || r.test(l)) continue;
                        int num = a[k] ^ a[l];
                        dp[i+2][j+num]=dp[i][j]+(1 << k)+(1 << l);
                    }
                }
            }
        }
    }

    rrep(i,7e7,0){
        if(dp[n-1][i]!=0) {
            cout << i << endl;
            return 0;
        }
    }
}
0