結果

問題 No.519 アイドルユニット
ユーザー tsutajtsutaj
提出日時 2017-05-29 23:05:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,079 bytes
コンパイル時間 2,327 ms
コンパイル使用メモリ 162,676 KB
実行使用メモリ 110,976 KB
最終ジャッジ日時 2024-04-10 05:59:08
合計ジャッジ時間 4,215 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 226 ms
110,848 KB
testcase_02 AC 65 ms
33,536 KB
testcase_03 AC 8 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 7 ms
6,944 KB
testcase_14 AC 8 ms
6,940 KB
testcase_15 AC 7 ms
6,944 KB
testcase_16 AC 7 ms
6,940 KB
testcase_17 AC 8 ms
6,940 KB
testcase_18 AC 7 ms
6,940 KB
testcase_19 AC 7 ms
6,944 KB
testcase_20 AC 8 ms
6,940 KB
testcase_21 AC 7 ms
6,944 KB
testcase_22 AC 8 ms
6,940 KB
testcase_23 AC 7 ms
6,944 KB
testcase_24 AC 20 ms
11,648 KB
testcase_25 AC 20 ms
11,648 KB
testcase_26 AC 19 ms
11,648 KB
testcase_27 AC 22 ms
11,648 KB
testcase_28 AC 22 ms
11,648 KB
testcase_29 AC 203 ms
110,720 KB
testcase_30 AC 220 ms
110,976 KB
testcase_31 AC 215 ms
110,720 KB
testcase_32 AC 211 ms
110,848 KB
testcase_33 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, board[25][25];
int memo[1<<24];

void solve(int S) {
    rep(i,0,N) {
        if(S >> i & 1) continue;
        rep(j,i+1,N) {
            if(S >> j & 1) continue;
            int nbit = S | (1<<i) | (1<<j);
            int ncost = memo[S] + board[i][j];
            if(ncost > memo[nbit]) {
                memo[nbit] = ncost;
                solve(nbit);
            }
        }
        break;
    }
}

signed main() {
    cin >> N;
    rep(i,0,N) rep(j,0,N) cin >> board[i][j];
    solve(0);
    cout << memo[(1<<N)-1] << endl;
    return 0;
}
0