結果

問題 No.519 アイドルユニット
ユーザー furafura
提出日時 2020-12-13 23:46:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 1,000 ms
コード長 494 bytes
コンパイル時間 1,978 ms
コンパイル使用メモリ 201,456 KB
実行使用メモリ 69,268 KB
最終ジャッジ日時 2023-10-20 04:32:21
合計ジャッジ時間 4,020 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
69,268 KB
testcase_01 AC 34 ms
69,268 KB
testcase_02 AC 23 ms
69,268 KB
testcase_03 AC 19 ms
69,268 KB
testcase_04 AC 19 ms
69,268 KB
testcase_05 AC 19 ms
69,268 KB
testcase_06 AC 19 ms
69,268 KB
testcase_07 AC 19 ms
69,268 KB
testcase_08 AC 19 ms
69,268 KB
testcase_09 AC 18 ms
69,268 KB
testcase_10 AC 19 ms
69,268 KB
testcase_11 AC 19 ms
69,268 KB
testcase_12 AC 19 ms
69,268 KB
testcase_13 AC 19 ms
69,268 KB
testcase_14 AC 19 ms
69,268 KB
testcase_15 AC 20 ms
69,268 KB
testcase_16 AC 19 ms
69,268 KB
testcase_17 AC 19 ms
69,268 KB
testcase_18 AC 19 ms
69,268 KB
testcase_19 AC 20 ms
69,268 KB
testcase_20 AC 19 ms
69,268 KB
testcase_21 AC 19 ms
69,268 KB
testcase_22 AC 20 ms
69,268 KB
testcase_23 AC 19 ms
69,268 KB
testcase_24 AC 21 ms
69,268 KB
testcase_25 AC 20 ms
69,268 KB
testcase_26 AC 20 ms
69,268 KB
testcase_27 AC 21 ms
69,268 KB
testcase_28 AC 21 ms
69,268 KB
testcase_29 AC 34 ms
69,268 KB
testcase_30 AC 33 ms
69,268 KB
testcase_31 AC 33 ms
69,268 KB
testcase_32 AC 33 ms
69,268 KB
testcase_33 AC 19 ms
69,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int n,A[24][24];

int memo[1<<24];

int dfs(int S){
	int& res=memo[S];
	if(res!=-1) return res;

	if(S==(1<<n)-1) return res=0;

	int i;
	for(i=0;S>>i&1;i++);

	res=0;
	for(int j=i+1;j<n;j++) if(~S>>j&1) {
		res=max(res,dfs(S|1<<i|1<<j)+A[i][j]);
	}
	return res;
}

int main(){
	scanf("%d",&n);
	rep(i,n) rep(j,n) scanf("%d",&A[i][j]);

	memset(memo,-1,sizeof memo);
	printf("%d\n",dfs(0));

	return 0;
}
0