結果

問題 No.519 アイドルユニット
ユーザー eiya5498513eiya5498513
提出日時 2017-05-28 21:48:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,060 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 96,136 KB
実行使用メモリ 33,216 KB
最終ジャッジ日時 2024-04-10 05:55:49
合計ジャッジ時間 5,361 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t map[25][25];

int32_t dp[1 << 24];
int32_t func(uint32_t bit)
{
	if (bit == 0) { return 0; }
	auto& memo = dp[bit];
	if (memo) { return memo; }

	int i=0;
	for (; i<N;++i)
	{
		if (bit&(1 << i)) {
			break;
		}
	}
	bit &= ~(1 << i);

	for (size_t j = 0; j < N; j++)
	{
		if (bit & (1<<j)) {
			memo = std::max(memo, func(bit&~(1 << j))+map[i][j]);
		}
	}
	return memo;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	for (size_t i = 0; i < N; i++)
		for (size_t j = 0; j < N; j++)
	{
			in >> map[i][j];
	}
	std::cout << func((1 << N) - 1) << endl;

	return 0;
}
#endif

0