結果

問題 No.698 ペアでチームを作ろう
ユーザー ngtkana
提出日時 2020-04-03 15:03:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 739 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 195,896 KB
最終ジャッジ日時 2025-01-09 12:40:51
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using lint=long long;
using real=long double;
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    lint N=1ll<<n;
    std::vector<lint>dp(N);
    for(lint bs=0;bs<N-1;bs++){
        if(__builtin_popcountll(bs)%2)continue;
        for(lint i=0;i<n;i++){
            if(bs>>i&1)continue;
            for(lint j=0;j<n;j++){
                if(i==j||bs>>j&1)continue;
                cmx(dp.at(bs|1ll<<i|1ll<<j),dp.at(bs)+(a.at(i)^a.at(j)));
            }
        }
    }
    std::cout<<dp.at(N-1)<<'\n';
}
0