結果
問題 | No.519 アイドルユニット |
ユーザー |
![]() |
提出日時 | 2017-05-28 22:30:19 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 948 bytes |
コンパイル時間 | 1,343 ms |
コンパイル使用メモリ | 159,516 KB |
実行使用メモリ | 16,960 KB |
最終ジャッジ日時 | 2024-09-21 15:38:36 |
合計ジャッジ時間 | 5,946 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | -- | - |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef unsigned long long ull; #define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) FOR(i, 0, n) template<class T> bool checkmax(T &a, T b) { return b > a ? a = b, 1 : 0; } int N; int table[24][24]; int dp[1 << 24]; void solve() { for (int mask = 2; mask < (1 << N); mask++) { int tmpMask = mask; for (; tmpMask != 0; ) { int a = __builtin_ctz(tmpMask); tmpMask -= 1 << a; int tmpMask2 = tmpMask; for (; tmpMask2 != 0; ) { int b = __builtin_ctz(tmpMask2); tmpMask2 -= 1 << b; checkmax(dp[mask], dp[mask ^ 1 << a ^ 1 << b] + table[a][b]); } } } cout << dp[(1 << N) - 1] << endl; } int main() { cin >> N; rep(a, N) rep(b, N) cin >> table[a][b]; solve(); return 0; }