結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー suisensuisen
提出日時 2022-12-24 03:18:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 1,000 ms
コード長 919 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 72,036 KB
実行使用メモリ 11,828 KB
最終ジャッジ日時 2023-08-11 12:21:49
合計ジャッジ時間 5,892 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
11,560 KB
testcase_01 AC 54 ms
11,540 KB
testcase_02 AC 40 ms
4,376 KB
testcase_03 AC 57 ms
11,520 KB
testcase_04 AC 58 ms
11,568 KB
testcase_05 AC 60 ms
11,544 KB
testcase_06 AC 58 ms
11,516 KB
testcase_07 AC 60 ms
11,592 KB
testcase_08 AC 56 ms
11,508 KB
testcase_09 AC 59 ms
11,592 KB
testcase_10 AC 60 ms
11,756 KB
testcase_11 AC 57 ms
11,548 KB
testcase_12 AC 60 ms
11,556 KB
testcase_13 AC 58 ms
11,556 KB
testcase_14 AC 60 ms
11,524 KB
testcase_15 AC 61 ms
11,524 KB
testcase_16 AC 58 ms
11,752 KB
testcase_17 AC 57 ms
11,520 KB
testcase_18 AC 57 ms
11,828 KB
testcase_19 AC 58 ms
11,684 KB
testcase_20 AC 55 ms
11,620 KB
testcase_21 AC 59 ms
11,516 KB
testcase_22 AC 59 ms
11,632 KB
testcase_23 AC 58 ms
11,816 KB
testcase_24 AC 59 ms
11,616 KB
testcase_25 AC 57 ms
11,568 KB
testcase_26 AC 58 ms
11,568 KB
testcase_27 AC 55 ms
11,656 KB
testcase_28 AC 48 ms
11,536 KB
testcase_29 AC 50 ms
11,548 KB
testcase_30 AC 51 ms
11,516 KB
testcase_31 AC 51 ms
11,820 KB
testcase_32 AC 52 ms
11,552 KB
testcase_33 AC 53 ms
11,760 KB
testcase_34 AC 53 ms
11,516 KB
testcase_35 AC 54 ms
11,568 KB
testcase_36 AC 55 ms
11,508 KB
testcase_37 AC 56 ms
11,644 KB
testcase_38 AC 56 ms
11,568 KB
testcase_39 AC 56 ms
11,524 KB
testcase_40 AC 58 ms
11,572 KB
testcase_41 AC 55 ms
11,564 KB
testcase_42 AC 56 ms
11,540 KB
testcase_43 AC 53 ms
11,540 KB
testcase_44 AC 52 ms
11,560 KB
testcase_45 AC 50 ms
11,684 KB
testcase_46 AC 52 ms
11,512 KB
testcase_47 AC 39 ms
4,380 KB
testcase_48 AC 61 ms
11,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <array>
#include <iostream>
#include <vector>

constexpr int N = 19;

std::array<std::array<uint64_t, 1 << N>, 2> dp{};

int main() {
    std::array<uint32_t, N> a{};
    for (int i = 0; i < N; ++i) {
        int l;
        std::cin >> l;
        for (int j = 0; j < l; ++j) {
            int v;
            std::cin >> v;
            a[i] |= 1u << (v - 1);
        }
    }

    dp[0][0] = 1;
    for (int s = 1; s < 1 << N; ++s) {
        int pc = __builtin_popcount(s);

        int z = 0;
        for (int i = N - 1; i >= 0; --i) {
            int b = 1 << i;
            if (s & b) {
                if (a[pc - 1] & b) {
                    for (int pz : { 0, 1 }) {
                        dp[pz ^ z][s] += dp[pz][s ^ (1 << i)];
                    }
                }
                z ^= 1;
            }
        }
    }
    std::cout << dp[0].back() << ' ' << dp[1].back() << std::endl;
    return 0;
}
0