結果

問題 No.698 ペアでチームを作ろう
ユーザー ryutaroukei8911ryutaroukei8911
提出日時 2018-08-22 20:29:16
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,191 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 83,256 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 18:17:58
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 6 ms
4,376 KB
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<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#include<bitset>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int dp[1<<20];//この集合のときの最大値
int n;int a[20];
int cnt=0;
int solve(int bit){cnt++;
    int &res=dp[bit];
    if(~res)return res;
    res=0;
    if(bit==0)return 0;
    rep(i,0,n){
        rep(j,i+1,n){
            if(j==i||!(bit&(1<<i))||!(bit&(1<<j)))continue;
            int h=bit&~(1<<i);h&=~(1<<j);
            res=max(res,solve(h)+a[i]^a[j]);
        }
    }
    dp[bit]=res;
   //cout<<res<<" "<<bit<<endl;
    return dp[bit];
}
signed main(){
    cin>>n;
    rep(i,0,n)cin>>a[i];
    memset(dp,-1,1<<18);
    cout<<solve((1<<n)-1)<<endl;
    //cout<<cnt<<endl;
    return 0;
    
}
0