結果

問題 No.519 アイドルユニット
ユーザー math_hiyokomath_hiyoko
提出日時 2020-12-14 02:16:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 180,400 KB
実行使用メモリ 6,488 KB
最終ジャッジ日時 2023-10-20 04:38:10
合計ジャッジ時間 3,527 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 91 ms
6,452 KB
testcase_02 AC 33 ms
4,672 KB
testcase_03 AC 5 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 3 ms
4,348 KB
testcase_11 AC 5 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 6 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 5 ms
4,348 KB
testcase_17 AC 5 ms
4,348 KB
testcase_18 AC 5 ms
4,348 KB
testcase_19 AC 5 ms
4,348 KB
testcase_20 AC 6 ms
4,348 KB
testcase_21 AC 5 ms
4,348 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 5 ms
4,348 KB
testcase_24 AC 12 ms
4,348 KB
testcase_25 AC 13 ms
4,348 KB
testcase_26 AC 12 ms
4,348 KB
testcase_27 AC 13 ms
4,348 KB
testcase_28 AC 14 ms
4,348 KB
testcase_29 AC 87 ms
6,448 KB
testcase_30 AC 99 ms
6,476 KB
testcase_31 AC 96 ms
6,472 KB
testcase_32 AC 86 ms
6,488 KB
testcase_33 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(){
    int N;
    cin >> N;
    int F[N][N];
    rep(i, N) rep(j, N) cin >> F[i][j];
    unordered_map<int, int> dp;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int c = que.front();
        que.pop();
        int j = 0;
        while((c & (1<<j))) j++;
        for(int k = j + 1; k < N; k++){
            if(c & (1<<k)) continue;
            int d = c + (1<<j) + (1<<k);
            if(dp[d] < dp[c] + F[j][k]){
                dp[d] = dp[c] + F[j][k];
                if(d != (1<<N) - 1) que.push(d);
            }
        }
    }
    cout << dp[(1<<N) - 1] << endl;
    return 0;
}
0