結果

問題 No.519 アイドルユニット
ユーザー finefine
提出日時 2017-05-28 22:36:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 737 bytes
コンパイル時間 1,594 ms
コンパイル使用メモリ 167,628 KB
実行使用メモリ 12,004 KB
最終ジャッジ日時 2023-10-21 14:25:35
合計ジャッジ時間 5,924 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef array< array<bool, 24>, 24> Matrix;

int n;
int f[24][24];

int solve(int cur, Matrix used) {
	if (cur == n) return 0;
	int res = 0;
	for (int i = 0; i < n; i++) {
		if (i == cur || used[cur][i]) continue;
		Matrix nex(used);
		for (int j = 0; j < n; j++) {
			nex[cur][j] = true;
			nex[j][cur] = true;
			nex[i][j] = true;
			nex[j][i] = true;
		}
		res = max(res, solve(cur + 1, nex) + f[cur][i]);
	}
	if (res == 0) return solve(cur + 1, used);
	return res;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> f[i][j];
		}
	}
	Matrix used{};
	cout << solve(0, used) << endl;
	return 0;
}
0