結果

問題 No.519 アイドルユニット
ユーザー furonfuron
提出日時 2023-10-26 23:23:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,620 bytes
コンパイル時間 1,442 ms
コンパイル使用メモリ 130,136 KB
実行使用メモリ 134,496 KB
最終ジャッジ日時 2023-10-26 23:24:02
合計ジャッジ時間 15,604 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream> 
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <random>

using namespace std;

using ll = long long;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>;
using vd = vector<double>; using vvd = vector<vd>;
using vs = vector<string>;
using pii = pair<int, int>; using vpii = vector<pii>;
using pil = pair<int, ll>; using vpil = vector<pil>;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using pdd = pair<double, double>; using vpdd = vector<pdd>;
const int inf = (1 << 30) - 1;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
const int MOD = 998244353;

template<typename T> inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); }


int main() {
	int n;
	cin >> n;
	vvi f(n, vi(n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int x;
			cin >> x;
			f[i][j] = f[j][i] = x;
		}
	}

	vl dp(1 << n, 0);

	for (int b = 0; b < (1 << n) - 1; b++) {
		int x = -1;
		for (int i = 0; i < n; i++) {
			if ((b & (1 << i)) == 0) {
				x = i;
				break;
			}
		}
		for (int i = 0; i < n; i++) {
			if ((b & (1 << i)) == 0) {
				int to = b | (1 << x) | (1 << i);
				chmax(dp[to], dp[b] + f[x][i]);
			}
		}
	}

	cout << dp[(1 << n) - 1] << endl;


	return 0;
}
0