結果

問題 No.519 アイドルユニット
ユーザー 👑 rin204rin204
提出日時 2022-11-08 19:16:04
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 917 bytes
コンパイル時間 4,843 ms
コンパイル使用メモリ 266,908 KB
実行使用メモリ 68,660 KB
最終ジャッジ日時 2023-09-29 08:43:20
合計ジャッジ時間 14,073 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 297 ms
19,408 KB
testcase_03 AC 19 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 18 ms
4,380 KB
testcase_14 AC 18 ms
4,380 KB
testcase_15 AC 18 ms
4,376 KB
testcase_16 AC 18 ms
4,376 KB
testcase_17 AC 19 ms
4,380 KB
testcase_18 AC 19 ms
4,380 KB
testcase_19 AC 18 ms
4,376 KB
testcase_20 AC 19 ms
4,384 KB
testcase_21 AC 19 ms
4,376 KB
testcase_22 AC 18 ms
4,376 KB
testcase_23 AC 18 ms
4,380 KB
testcase_24 AC 72 ms
7,216 KB
testcase_25 AC 72 ms
7,196 KB
testcase_26 AC 71 ms
7,148 KB
testcase_27 AC 72 ms
7,148 KB
testcase_28 AC 71 ms
7,140 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 2 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);
	int S;
	for(int bit = 0; bit < (1 << n - 1) - 1; bit++){
		bool pc = 0;
		int ii = -1;
		for(int i = 0; i < n - 1; i++){
			if(bit >> i & 1) pc ^= 1;
			else if(ii == -1){
				ii = i;
			}
		}
		S = bit;
		if(pc) S |= 1 << (n - 1);
		for(int i = 0; i < n; i++){
			if(S >> i & 1);
			else{
				chmax(dp[S | (1 << i) | (1 << ii)], dp[S] + F[i][ii]);
			}
		}	
	}
	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