結果

問題 No.519 アイドルユニット
ユーザー mamekinmamekin
提出日時 2017-06-03 01:49:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 1,000 ms
コード長 1,146 bytes
コンパイル時間 1,168 ms
コンパイル使用メモリ 107,164 KB
実行使用メモリ 68,884 KB
最終ジャッジ日時 2024-04-14 06:45:23
合計ジャッジ時間 2,635 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
68,776 KB
testcase_01 AC 52 ms
68,828 KB
testcase_02 AC 16 ms
19,580 KB
testcase_03 AC 4 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 4 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 4 ms
6,944 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 4 ms
6,940 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 4 ms
6,944 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 6 ms
7,504 KB
testcase_25 AC 6 ms
7,272 KB
testcase_26 AC 7 ms
7,300 KB
testcase_27 AC 7 ms
7,340 KB
testcase_28 AC 8 ms
7,444 KB
testcase_29 AC 53 ms
68,716 KB
testcase_30 AC 52 ms
68,884 KB
testcase_31 AC 51 ms
68,784 KB
testcase_32 AC 53 ms
68,872 KB
testcase_33 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > f(n, vector<int>(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cin >> f[i][j];
        }
    }

    vector<int> dp(1<<n, -1);
    dp[0] = 0;
    for(int i=0; i<(1<<n)-1; ++i){
        if(dp[i] == -1)
            continue;

        bitset<32> bs(i);
        int j = 0;
        while(bs[j])
            ++ j;
        bs[j] = true;

        for(int k=j+1; k<n; ++k){
            if(bs[k])
                continue;
            bs[k] = true;
            dp[bs.to_ulong()] = max(dp[bs.to_ulong()], dp[i] + f[j][k]);
            bs[k] = false;
        }
    }
    cout << dp.back() << endl;

    return 0;
}
0