結果

問題 No.519 アイドルユニット
ユーザー ferinferin
提出日時 2019-10-26 15:54:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,137 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 166,904 KB
実行使用メモリ 11,844 KB
最終ジャッジ日時 2023-10-12 11:09:42
合計ジャッジ時間 6,576 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

ll n, f[24][24];
ll dfs(ll idx, ll num, vector<int> used) {
    if(idx == n) {
        if(num*2 == n) return 0;
        return -INF;
    }
    ll ret = dfs(idx+1, num, used);
    REP(i, n) {
        if(used[i]==1 || used[idx]==1 || idx == i) continue;
        used[idx] = used[i] = 1;
        num++;
        chmax(ret, dfs(idx+1, num, used) + f[idx][i]);
        used[idx] = used[i] = 0;
        num--; 
    }
    return ret;
}

int main(void) {
    cin >> n;
    REP(i, n) REP(j, n) cin >> f[i][j];

    vector<int> used(n, 0);
    cout << dfs(0, 0, used) << endl;

    return 0;
}
0