結果

問題 No.519 アイドルユニット
ユーザー chocoruskchocorusk
提出日時 2018-12-21 16:36:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 90 ms / 1,000 ms
コード長 913 bytes
コンパイル時間 744 ms
コンパイル使用メモリ 96,708 KB
実行使用メモリ 68,960 KB
最終ジャッジ日時 2023-10-26 01:32:38
合計ジャッジ時間 3,653 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
68,960 KB
testcase_01 AC 89 ms
68,960 KB
testcase_02 AC 56 ms
68,960 KB
testcase_03 AC 47 ms
68,960 KB
testcase_04 AC 46 ms
68,960 KB
testcase_05 AC 46 ms
68,960 KB
testcase_06 AC 45 ms
68,960 KB
testcase_07 AC 46 ms
68,960 KB
testcase_08 AC 45 ms
68,960 KB
testcase_09 AC 45 ms
68,960 KB
testcase_10 AC 45 ms
68,960 KB
testcase_11 AC 47 ms
68,960 KB
testcase_12 AC 46 ms
68,960 KB
testcase_13 AC 46 ms
68,960 KB
testcase_14 AC 46 ms
68,960 KB
testcase_15 AC 46 ms
68,960 KB
testcase_16 AC 46 ms
68,960 KB
testcase_17 AC 46 ms
68,960 KB
testcase_18 AC 46 ms
68,960 KB
testcase_19 AC 46 ms
68,960 KB
testcase_20 AC 46 ms
68,960 KB
testcase_21 AC 46 ms
68,960 KB
testcase_22 AC 46 ms
68,960 KB
testcase_23 AC 47 ms
68,960 KB
testcase_24 AC 49 ms
68,960 KB
testcase_25 AC 48 ms
68,960 KB
testcase_26 AC 48 ms
68,960 KB
testcase_27 AC 48 ms
68,960 KB
testcase_28 AC 48 ms
68,960 KB
testcase_29 AC 90 ms
68,960 KB
testcase_30 AC 90 ms
68,960 KB
testcase_31 AC 89 ms
68,960 KB
testcase_32 AC 87 ms
68,960 KB
testcase_33 AC 46 ms
68,960 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:38:21: warning: ‘k’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |                 int k;
      |                     ^

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#define bitcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n;
	cin>>n;
	int f[24][24];
	for(int i=0; i<n; i++){
		for(int j=0; j<n; j++){
			cin>>f[i][j];
		}
	}
	int dp[1<<24];
	fill(dp, dp+(1<<n), -1);
	dp[0]=0;
	for(int i=0; i<(1<<n)-1; i++){
	    if(dp[i]==-1) continue;
		int k;
		for(int j=0; j<n; j++){
			if((i&(1<<j))==0){
				k=j;
				break;
			}
		}
		for(int j=k+1; j<n; j++){
			if(i&(1<<j)) continue;
			dp[i|(1<<j)|(1<<k)]=max(dp[i|(1<<j)|(1<<k)], dp[i]+f[j][k]);
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}
0