結果

問題 No.698 ペアでチームを作ろう
ユーザー matsukin1111matsukin1111
提出日時 2019-06-06 15:35:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,378 bytes
コンパイル時間 990 ms
コンパイル使用メモリ 95,504 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-26 01:45:41
合計ジャッジ時間 1,671 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
using R = double;
using Data = pair < ll, vector <ll>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll, ll>pll;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

int N,A[20],memo[1<<14];
int rec(int msk){
	if (memo[msk] != -1)return memo[msk];
	if (msk == 0)return 0;
	int ret = 0;
	pair<int, int>p = {-1,-1};
	rep(i, 0, N)rep(j, i+1, N) {
		if ((1<<i & msk) && (1<<j & msk)) {
			int temp = rec(msk - (1 << i) - (1 << j));
			if (p.first == -1 || temp > ret) {
				ret = temp;
				p = { i,j };
			}
		}
	}
	int t= A[p.first] ^ A[p.second];
	return memo[msk] = ret + t;
}

int main(){
	cin >> N;
	rep(i, 0, N)cin >> A[i];
	memset(memo, -1, sizeof(memo));
	cout << rec((1<<N)-1) << endl;
	return 0;
}

0