結果

問題 No.519 アイドルユニット
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2017-06-09 16:28:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 1,163 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 158,080 KB
実行使用メモリ 265,784 KB
最終ジャッジ日時 2024-04-10 11:35:54
合計ジャッジ時間 5,721 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
265,756 KB
testcase_01 AC 114 ms
265,580 KB
testcase_02 AC 80 ms
265,664 KB
testcase_03 AC 68 ms
265,712 KB
testcase_04 AC 67 ms
265,576 KB
testcase_05 AC 67 ms
265,588 KB
testcase_06 AC 66 ms
265,732 KB
testcase_07 AC 66 ms
265,744 KB
testcase_08 AC 67 ms
265,576 KB
testcase_09 AC 67 ms
265,680 KB
testcase_10 AC 68 ms
265,704 KB
testcase_11 AC 67 ms
265,588 KB
testcase_12 AC 66 ms
265,636 KB
testcase_13 AC 69 ms
265,596 KB
testcase_14 AC 68 ms
265,692 KB
testcase_15 AC 67 ms
265,696 KB
testcase_16 AC 68 ms
265,740 KB
testcase_17 AC 66 ms
265,552 KB
testcase_18 AC 66 ms
265,620 KB
testcase_19 AC 68 ms
265,752 KB
testcase_20 AC 68 ms
265,568 KB
testcase_21 AC 68 ms
265,772 KB
testcase_22 AC 67 ms
265,720 KB
testcase_23 AC 67 ms
265,552 KB
testcase_24 AC 70 ms
265,740 KB
testcase_25 AC 69 ms
265,784 KB
testcase_26 AC 70 ms
265,696 KB
testcase_27 AC 69 ms
265,748 KB
testcase_28 AC 69 ms
265,740 KB
testcase_29 AC 110 ms
265,684 KB
testcase_30 AC 111 ms
265,628 KB
testcase_31 AC 112 ms
265,760 KB
testcase_32 AC 109 ms
265,596 KB
testcase_33 AC 67 ms
265,628 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:34:21: warning: ‘p1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |                 int p1;
      |                     ^~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int n;
int F[30][30];
int dp[(1 << 26)];
int main(void){
	cin >> n;
	rep(i, n)rep(j, n) cin >> F[i][j];
	rep(i, (1<<26)) dp[i] = -1;
	dp[0] = 0;
	for (int mask = 0; mask < (1<<n) - 1; ++mask){
		if(dp[mask] == -1) continue;
		int tmpmask = mask;
		int p1;
		rep(i, n)if((mask & (1<<i)) == 0){
			p1 = i; break;
		}
		tmpmask |= (1<<p1);
		rep(p2, n)if((tmpmask & (1<<p2)) == 0){
			chmax(dp[tmpmask | (1<<p2)], dp[mask] + F[p1][p2]);
		}
	}
	printf("%d\n", dp[(1<<n) - 1]);
	return 0;
}
0