結果

問題 No.519 アイドルユニット
ユーザー eitahoeitaho
提出日時 2017-05-28 22:12:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 1,255 ms
コンパイル使用メモリ 159,276 KB
実行使用メモリ 7,740 KB
最終ジャッジ日時 2023-10-21 14:16:04
合計ジャッジ時間 3,729 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 39 ms
4,672 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
testcase_10 AC 9 ms
4,348 KB
testcase_11 AC 38 ms
4,672 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 38 ms
4,672 KB
testcase_14 AC 40 ms
4,672 KB
testcase_15 AC 38 ms
4,672 KB
testcase_16 AC 37 ms
4,672 KB
testcase_17 AC 39 ms
4,672 KB
testcase_18 AC 38 ms
4,672 KB
testcase_19 AC 37 ms
4,672 KB
testcase_20 AC 40 ms
4,672 KB
testcase_21 AC 39 ms
4,672 KB
testcase_22 AC 39 ms
4,672 KB
testcase_23 AC 40 ms
4,672 KB
testcase_24 AC 184 ms
7,740 KB
testcase_25 AC 177 ms
7,740 KB
testcase_26 AC 182 ms
7,740 KB
testcase_27 AC 177 ms
7,740 KB
testcase_28 AC 194 ms
7,740 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) FOR(i, 0, n)
template<class T> bool checkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

int N;
int table[20][20];
int dp[1 << 20];

void solve() {
    for (int mask = 2; mask < (1 << N); mask++)
    {
        int tmpMask = mask;
        for (; tmpMask != 0; )
        {
            int a = __builtin_ctz(tmpMask);
            tmpMask -= 1 << a;
            int tmpMask2 = tmpMask;
            for (; tmpMask2 != 0; )
            {
                int b = __builtin_ctz(tmpMask2);
                tmpMask2 -= 1 << b;
                checkmax(dp[mask], dp[mask ^ 1 << a ^ 1 << b] + table[a][b]);
            }
        }
    }
    int ans = 0;
    rep(mask, 1 << N) checkmax(ans, dp[mask]);
    cout << ans << endl;
}

int main() {
    cin >> N;
    rep(a, N) rep(b, N) cin >> table[a][b];
    solve();
    return 0;
}
0