結果

問題 No.698 ペアでチームを作ろう
ユーザー house_guardhouse_guard
提出日時 2024-01-04 18:15:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,070 bytes
コンパイル時間 3,684 ms
コンパイル使用メモリ 207,544 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-04 18:15:56
合計ジャッジ時間 3,490 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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>((1 << n)+1,-1));
    rep(i,0,n){
        rep(j,i+1,n){
            int val=a[i]^a[j];
            dp[1][(1 << i)+(1 << j)]=val;
        }
    }
    rep(i,1,n-2){
        rep(j,1,dp[i].size()){
            if(dp[i][j]>=0){
                bitset<16> r(j);
                rep(k,0,n){
                    rep(l,k+1,n){
                        if(r.test(k) || r.test(l)) continue;
                        dp[i+2][j+(1 << k)+(1 << l)]=dp[i][j]+(a[k]^a[l]);
                    }
                }
            }
        }
    }
    
    int ans = 0;
    rep(i,0,dp[n-1].size()){
        ans = max(ans,dp[n-1][i]);
    }
    cout << ans << endl;
}
0