結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー trineutron
提出日時 2022-12-09 08:47:52
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 175 ms / 1,000 ms
コード長 1,004 bytes
コンパイル時間 2,682 ms
コンパイル使用メモリ 247,328 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-10-14 18:34:23
合計ジャッジ時間 10,800 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

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