結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー t98slidert98slider
提出日時 2022-12-09 00:36:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 163 ms / 1,000 ms
コード長 849 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 168,344 KB
実行使用メモリ 32,000 KB
最終ジャッジ日時 2024-04-22 18:49:29
合計ジャッジ時間 8,229 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
31,780 KB
testcase_01 AC 49 ms
31,872 KB
testcase_02 AC 50 ms
31,872 KB
testcase_03 AC 161 ms
31,872 KB
testcase_04 AC 81 ms
31,796 KB
testcase_05 AC 161 ms
31,872 KB
testcase_06 AC 75 ms
31,872 KB
testcase_07 AC 80 ms
31,872 KB
testcase_08 AC 65 ms
31,744 KB
testcase_09 AC 106 ms
31,876 KB
testcase_10 AC 131 ms
31,872 KB
testcase_11 AC 107 ms
31,868 KB
testcase_12 AC 129 ms
31,872 KB
testcase_13 AC 78 ms
31,992 KB
testcase_14 AC 106 ms
31,836 KB
testcase_15 AC 110 ms
31,872 KB
testcase_16 AC 85 ms
31,744 KB
testcase_17 AC 158 ms
31,848 KB
testcase_18 AC 101 ms
31,872 KB
testcase_19 AC 157 ms
31,744 KB
testcase_20 AC 51 ms
31,744 KB
testcase_21 AC 99 ms
31,744 KB
testcase_22 AC 127 ms
31,900 KB
testcase_23 AC 84 ms
31,784 KB
testcase_24 AC 163 ms
31,712 KB
testcase_25 AC 88 ms
32,000 KB
testcase_26 AC 146 ms
31,932 KB
testcase_27 AC 96 ms
31,872 KB
testcase_28 AC 47 ms
32,000 KB
testcase_29 AC 48 ms
31,848 KB
testcase_30 AC 50 ms
31,920 KB
testcase_31 AC 47 ms
31,872 KB
testcase_32 AC 50 ms
31,744 KB
testcase_33 AC 60 ms
31,872 KB
testcase_34 AC 68 ms
31,964 KB
testcase_35 AC 81 ms
32,000 KB
testcase_36 AC 100 ms
31,844 KB
testcase_37 AC 121 ms
31,872 KB
testcase_38 AC 141 ms
31,872 KB
testcase_39 AC 155 ms
31,872 KB
testcase_40 AC 158 ms
31,872 KB
testcase_41 AC 160 ms
31,872 KB
testcase_42 AC 158 ms
31,744 KB
testcase_43 AC 160 ms
31,744 KB
testcase_44 AC 148 ms
31,784 KB
testcase_45 AC 133 ms
31,872 KB
testcase_46 AC 136 ms
31,772 KB
testcase_47 AC 48 ms
31,872 KB
testcase_48 AC 100 ms
31,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> S(19);
    for(int i = 0; i < 19; i++){
        int L, v;
        cin >> L;
        while(L--){
            cin >> v;
            S[i] |= 1 << v - 1;
        }
    }
    vector<vector<ll>> dp(1 << 19, vector<ll>(2));
    dp[0][0] = 1;
    for(int i = 0; i < (1 << 19); i++){
        for(int j = 0; j < 2; j++){
            if(dp[i][j] == 0)continue;
            int p = __builtin_popcount(i), cnt = 0;
            for(int k = 0; k < 19; k++){
                if(i >> k & 1)continue;
                cnt++;
                if(~S[k] >> p & 1)continue;
                dp[i | (1 << k)][j ^ (cnt & 1) ^ 1] += dp[i][j];
            }
        }
    }
    cout << dp.back()[0] << ' ' << dp.back()[1] << '\n';
}
0