結果

問題 No.519 アイドルユニット
ユーザー 👑 rin204rin204
提出日時 2022-11-08 19:33:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 853 bytes
コンパイル時間 4,410 ms
コンパイル使用メモリ 267,700 KB
実行使用メモリ 68,692 KB
最終ジャッジ日時 2023-09-29 08:54:53
合計ジャッジ時間 5,825 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
68,460 KB
testcase_01 AC 46 ms
68,500 KB
testcase_02 AC 14 ms
19,516 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 6 ms
7,256 KB
testcase_25 AC 6 ms
7,244 KB
testcase_26 AC 5 ms
7,204 KB
testcase_27 AC 5 ms
7,260 KB
testcase_28 AC 5 ms
7,092 KB
testcase_29 AC 46 ms
68,484 KB
testcase_30 AC 47 ms
68,504 KB
testcase_31 AC 46 ms
68,432 KB
testcase_32 AC 45 ms
68,692 KB
testcase_33 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<atcoder/scc>
using namespace std;
// using namespace atcoder;


void chmax(int &a, int b){
	if(a < b) a = b;
}

void solve(){    
	int n;
	cin >> n;
	vector<vector<int>> F(n, vector<int>(n));
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) cin >> F[i][j];
	vector<int> dp(1 << n, -1);
	dp[0] = 0;
	for(int bit = 0; bit < (1 << n) - 1; bit++){
		if(dp[bit] < 0) continue;
		for(int i = 0; i < n; i++){
			if(bit >> i & 1) continue;
			for(int j = i + 1; j < n; j++){
				if(bit >> j & 1) continue;
				chmax(dp[bit | (1 << i) | (1 << j)], dp[bit] + F[i][j]);
			}
			break;
		}
	}
	cout << dp[(1 << n) - 1] << "\n";
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int t;
	t = 1;
	// cin >> t;
	while(t--) solve();
}
	
	
0