結果

問題 No.519 アイドルユニット
ユーザー chocorusk
提出日時 2018-12-21 16:13:53
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 872 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 95,664 KB
実行使用メモリ 68,992 KB
最終ジャッジ日時 2024-09-25 09:32:06
合計ジャッジ時間 13,965 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28 TLE * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:25: warning: ‘k’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |                         if(j==k) continue;
      |                         ^~

ソースコード

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]={};
	for(int i=0; i<(1<<n)-1; i++){
		int k;
		for(int j=0; j<n; j++){
			if((i&(1<<j))==0){
				k=j;
				break;
			}
		}
		for(int j=0; j<n; j++){
			if(i&(1<<j)) continue;
			if(j==k) 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