結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー trineutrontrineutron
提出日時 2022-12-09 08:47:52
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 1,000 ms
コード長 1,004 bytes
コンパイル時間 3,263 ms
コンパイル使用メモリ 276,684 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-22 19:01:55
合計ジャッジ時間 10,684 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
11,392 KB
testcase_01 AC 112 ms
11,392 KB
testcase_02 AC 104 ms
11,392 KB
testcase_03 AC 137 ms
11,392 KB
testcase_04 AC 125 ms
11,392 KB
testcase_05 AC 136 ms
11,392 KB
testcase_06 AC 130 ms
11,392 KB
testcase_07 AC 142 ms
11,520 KB
testcase_08 AC 133 ms
11,392 KB
testcase_09 AC 120 ms
11,392 KB
testcase_10 AC 124 ms
11,392 KB
testcase_11 AC 122 ms
11,520 KB
testcase_12 AC 131 ms
11,392 KB
testcase_13 AC 125 ms
11,392 KB
testcase_14 AC 139 ms
11,392 KB
testcase_15 AC 129 ms
11,392 KB
testcase_16 AC 124 ms
11,264 KB
testcase_17 AC 129 ms
11,520 KB
testcase_18 AC 139 ms
11,392 KB
testcase_19 AC 136 ms
11,392 KB
testcase_20 AC 119 ms
11,392 KB
testcase_21 AC 123 ms
11,392 KB
testcase_22 AC 130 ms
11,392 KB
testcase_23 AC 124 ms
11,392 KB
testcase_24 AC 132 ms
11,520 KB
testcase_25 AC 129 ms
11,392 KB
testcase_26 AC 146 ms
11,392 KB
testcase_27 AC 114 ms
11,392 KB
testcase_28 AC 112 ms
11,392 KB
testcase_29 AC 108 ms
11,520 KB
testcase_30 AC 111 ms
11,392 KB
testcase_31 AC 109 ms
11,520 KB
testcase_32 AC 112 ms
11,392 KB
testcase_33 AC 116 ms
11,392 KB
testcase_34 AC 121 ms
11,392 KB
testcase_35 AC 121 ms
11,392 KB
testcase_36 AC 124 ms
11,392 KB
testcase_37 AC 119 ms
11,520 KB
testcase_38 AC 124 ms
11,392 KB
testcase_39 AC 122 ms
11,392 KB
testcase_40 AC 126 ms
11,392 KB
testcase_41 AC 132 ms
11,392 KB
testcase_42 AC 136 ms
11,392 KB
testcase_43 AC 153 ms
11,392 KB
testcase_44 AC 149 ms
11,392 KB
testcase_45 AC 155 ms
11,520 KB
testcase_46 AC 149 ms
11,392 KB
testcase_47 AC 106 ms
11,392 KB
testcase_48 AC 135 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int mask = (1 << 19) - 1;
constexpr int top = 1 << 19;

int main() {
    vector<int> a(19);
    for (int i = 0; i < 19; i++) {
        int l;
        cin >> l;
        for (int j = 0; j < l; j++) {
            int x;
            cin >> x;
            x--;
            a.at(i) ^= 1 << x;
        }
    }

    vector<int64_t> ans(1 << 20);
    ans.at(0) = 1;
    for (int i = 0; i < 19; i++) {
        for (int j = 0; j < 1 << 20; j++) {
            if (__builtin_popcount(j & mask) != i) continue;
            for (int k = 0; k < 19; k++) {
                if ((a.at(i) >> k & 1) and not(j >> k & 1)) {
                    bool flip =
                        __builtin_popcount(j & mask & ~((1 << k) - 1)) % 2 == 1;
                    int t = flip ? top : 0;
                    ans.at(j ^ (1 << k) ^ t) += ans.at(j);
                }
            }
        }
    }

    cout << ans.at(mask) << ' ' << ans.at(mask ^ top) << endl;

    return 0;
}
0