結果
| 問題 |
No.519 アイドルユニット
|
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2017-04-09 19:26:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,918 bytes |
| コンパイル時間 | 1,597 ms |
| コンパイル使用メモリ | 166,816 KB |
| 実行使用メモリ | 79,488 KB |
| 最終ジャッジ日時 | 2024-09-15 08:02:53 |
| 合計ジャッジ時間 | 6,100 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;
template <typename T>
void __dump__(std::ostream &os, const T &first) {
os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
os << first << ", ";
__dump__(os, rest...);
}
#define dump(...) \
do { \
std::ostringstream os; \
os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
__dump__(os, __VA_ARGS__); \
std::cerr << os.str() << std::endl; \
} while (0)
int dp[1<<24];
int f[24][24];
int n;
// int rec(int S) {
// int &res = dp[S];
// if (res != -1) return res;
// if (S + 1 == 1 << n) {
// res = 0;
// } else {
// rep(i, n) rep(j, n) {
// if(i == j || S >> i & 1 || S >> j & 1) continue;
// int cand = rec(S | 1 << i | 1 << j) + f[i][j];
// res = max(res, cand);
// }
// }
// return res;
// }
int main() {
while (cin >> n) {
memset(dp, -1, sizeof dp);
rep(i, n) rep(j, n) cin >> f[i][j];
dp[0] = 0;
rep(S, 1<<n) {
rep(i, n) rep(j, n) {
if (i == j || S >> i & 1 || S >> j & 1) continue;
int cand = f[i][j] + dp[S];
int nS = S|1<<i|1<<j;
dp[nS] = max(dp[nS], cand);
}
}
cout << dp[(1 << n) - 1] << endl;
}
}
tubo28