結果

問題 No.519 アイドルユニット
ユーザー ransewhaleransewhale
提出日時 2020-12-15 07:57:58
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,179 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 76,876 KB
実行使用メモリ 8,276 KB
最終ジャッジ日時 2023-10-20 05:45:58
合計ジャッジ時間 3,130 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

std::map<int, ll> dp[15];
std::map<int, ll>::iterator itr;

ll f[25][25];

int main(void){
	int n,m,i,j,mask,l,r,t;
	bool flag;
	std::cin >> n; m = n/2;
	for(i=0; i<n; ++i){
		for(j=0; j<n; ++j){
			std::cin >> f[i][j];
		}
	}
	dp[0][0] = 0ll;
	for(i=0; i<m; ++i){
		for(itr = dp[i].begin(); itr != dp[i].end(); ++itr){
			mask = (*itr).first;
			for(j=0; j<n; ++j){
				if(!(mask&(1<<j))){
					l = j;
					for(r=j+1; r<n; ++r){
						if(mask&(1<<r)){
							continue;
						}
						t = mask+(1<<l)+(1<<r);
						if(dp[i+1].find(t) == dp[i+1].end()){
							dp[i+1][t] = (*itr).first + f[l][r];
						}else{
							dp[i+1][t] = std::max(dp[i+1][t],(*itr).second + f[l][r]);
						}
					}
					break;
				}
			}
		}
	}
	std::cout << dp[m][(1<<n)-1] << std::endl;
	return 0;
}
0