結果
問題 | No.519 アイドルユニット |
ユーザー |
![]() |
提出日時 | 2017-05-28 23:48:05 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,969 bytes |
コンパイル時間 | 854 ms |
コンパイル使用メモリ | 94,380 KB |
実行使用メモリ | 179,840 KB |
最終ジャッジ日時 | 2024-09-21 16:01:12 |
合計ジャッジ時間 | 5,252 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 <iostream> #include <cstdio> #include <cstring> #include <string> #include <stack> #include <queue> #include <functional> #include <algorithm> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <vector> #include <array> #include <tuple> #include <utility> #include <numeric> #include <iomanip> #include <cctype> #include <cmath> #include <assert.h> #include <cstdlib> #include <list> using namespace std; using ll = long long; using ull = unsigned long long; using PII = pair<int, int>; using PLL = pair<ll, ll>; template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) { return s << "(" << p.first << ", " << p.second << ")"; } template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { s << "["; for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i]; s << "]"; return s; } #define ALL(a) (a).begin(), (a).end() int size[1 << 24], dp[1 << 24], cost[1 << 24]; int table[24][24]; int main() { int n; cin >> n; for (int r = 0; r < n; r++) { for (int c = 0; c < n; c++) { cin >> table[r][c]; } } for (int mask = 0; mask < (1 << n); mask++) { for (int i = 0; i < n; i++) { if ((mask >> i) & 1) size[mask]++; } } vector<PII> foo; for (int a = 0; a < n; a++) { for (int b = a + 1; b < n; b++) { cost[(1 << a) | (1 << b)] = table[a][b]; foo.push_back(make_pair((1 << a) | (1 << b), table[a][b])); } } memset(dp, -1, sizeof(dp)); dp[(1 << n) - 1] = 0; for (int mask = (1 << n) - 1; mask > 0; mask--) { if (dp[mask] < 0 || size[mask] % 2 == 1) continue; for (PII& f : foo) { if ((mask & f.first) == f.first) { dp[mask ^ f.first] = max(dp[mask ^ f.first], dp[mask] + f.second); } } } cout << dp[0] << endl; return 0; }