結果
| 問題 |
No.698 ペアでチームを作ろう
|
| ユーザー |
🍮かんプリン
|
| 提出日時 | 2019-08-26 20:09:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,215 bytes |
| コンパイル時間 | 2,276 ms |
| コンパイル使用メモリ | 169,564 KB |
| 実行使用メモリ | 10,624 KB |
| 最終ジャッジ日時 | 2024-11-08 02:00:32 |
| 合計ジャッジ時間 | 4,676 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 1 -- * 10 |
ソースコード
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = MOD - 1;
const ll LLINF = 4e18;
int bit_count(int n) {
int cnt = 0;
while (n != 0) {
if (n % 2 == 1) cnt++;
n >>= 1;
}
return cnt;
}
// まだ使っってないものがS
ll power(int S, int n,vector<ll>& dp,const vector<int>& a) {
if (dp[S] >= 0) return dp[S];
if (S == (1<<n)-1) return dp[S] = 0;
ll res = 0;
REP(i, n) {
REP(j, n) {
if (i == j) continue;
// 既に使われている
if ((S | (1 << i)) == S || (S | (1 << j)) == S) continue;
res = max(res, power(S | (1 << i) | (1 << j), n, dp,a) + (a[i] ^ a[j]));
}
}
return res;
}
int main() {
int n; cin >> n;
vector<ll> dp(1 << n,-1);
vector<int> a(n);
REP(i, n) {
cin >> a[i];
}
cout << power(0, n, dp, a) << endl;
getchar(); getchar();
}
🍮かんプリン