結果

問題 No.519 アイドルユニット
ユーザー tubo28tubo28
提出日時 2017-04-09 19:32:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,593 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 167,732 KB
実行使用メモリ 69,272 KB
最終ジャッジ日時 2023-10-21 13:57:50
合計ジャッジ時間 16,245 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 439 ms
69,220 KB
testcase_03 AC 43 ms
69,220 KB
testcase_04 AC 18 ms
69,220 KB
testcase_05 AC 18 ms
69,220 KB
testcase_06 AC 20 ms
69,220 KB
testcase_07 AC 19 ms
69,220 KB
testcase_08 AC 19 ms
69,220 KB
testcase_09 AC 20 ms
69,220 KB
testcase_10 AC 24 ms
69,220 KB
testcase_11 AC 42 ms
69,220 KB
testcase_12 AC 19 ms
69,220 KB
testcase_13 AC 42 ms
69,220 KB
testcase_14 AC 43 ms
69,220 KB
testcase_15 AC 42 ms
69,220 KB
testcase_16 AC 42 ms
69,220 KB
testcase_17 AC 43 ms
69,220 KB
testcase_18 AC 43 ms
69,220 KB
testcase_19 AC 43 ms
69,220 KB
testcase_20 AC 42 ms
69,220 KB
testcase_21 AC 43 ms
69,220 KB
testcase_22 AC 43 ms
69,220 KB
testcase_23 AC 42 ms
69,220 KB
testcase_24 AC 119 ms
69,220 KB
testcase_25 AC 120 ms
69,220 KB
testcase_26 AC 119 ms
69,220 KB
testcase_27 AC 119 ms
69,220 KB
testcase_28 AC 119 ms
69,220 KB
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 19 ms
69,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 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) {
            int i = 0;
            while (S >> i & 1) ++i;
            rep(j, n) {
                if (i == j) continue;
                if (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;
    }
}
0