結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー ぷらぷら
提出日時 2022-12-13 06:10:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 1,000 ms
コード長 914 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 202,896 KB
実行使用メモリ 11,820 KB
最終ジャッジ日時 2023-08-06 23:21:21
合計ジャッジ時間 8,758 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
11,556 KB
testcase_01 AC 65 ms
11,656 KB
testcase_02 AC 52 ms
4,380 KB
testcase_03 AC 91 ms
11,540 KB
testcase_04 AC 78 ms
11,620 KB
testcase_05 AC 88 ms
11,632 KB
testcase_06 AC 79 ms
11,700 KB
testcase_07 AC 84 ms
11,616 KB
testcase_08 AC 84 ms
11,596 KB
testcase_09 AC 80 ms
11,488 KB
testcase_10 AC 77 ms
11,576 KB
testcase_11 AC 81 ms
11,672 KB
testcase_12 AC 82 ms
11,552 KB
testcase_13 AC 76 ms
11,568 KB
testcase_14 AC 91 ms
11,484 KB
testcase_15 AC 86 ms
11,548 KB
testcase_16 AC 75 ms
11,600 KB
testcase_17 AC 79 ms
11,568 KB
testcase_18 AC 90 ms
11,564 KB
testcase_19 AC 86 ms
11,492 KB
testcase_20 AC 73 ms
11,632 KB
testcase_21 AC 77 ms
11,552 KB
testcase_22 AC 86 ms
11,552 KB
testcase_23 AC 79 ms
11,484 KB
testcase_24 AC 88 ms
11,480 KB
testcase_25 AC 81 ms
11,664 KB
testcase_26 AC 88 ms
11,548 KB
testcase_27 AC 70 ms
11,536 KB
testcase_28 AC 59 ms
11,696 KB
testcase_29 AC 60 ms
11,496 KB
testcase_30 AC 62 ms
11,500 KB
testcase_31 AC 63 ms
11,520 KB
testcase_32 AC 64 ms
11,644 KB
testcase_33 AC 65 ms
11,544 KB
testcase_34 AC 67 ms
11,564 KB
testcase_35 AC 68 ms
11,600 KB
testcase_36 AC 70 ms
11,552 KB
testcase_37 AC 74 ms
11,488 KB
testcase_38 AC 78 ms
11,752 KB
testcase_39 AC 81 ms
11,556 KB
testcase_40 AC 86 ms
11,496 KB
testcase_41 AC 91 ms
11,568 KB
testcase_42 AC 96 ms
11,620 KB
testcase_43 AC 101 ms
11,480 KB
testcase_44 AC 104 ms
11,564 KB
testcase_45 AC 106 ms
11,820 KB
testcase_46 AC 112 ms
11,596 KB
testcase_47 AC 53 ms
4,380 KB
testcase_48 AC 88 ms
11,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long dp[1 << 19][2];

int main() {
    vector<vector<int>>A(19);
    for(int i = 0; i < 19; i++) {
        int L;
        cin >> L;
        A[i].resize(L);
        for(int j = 0; j < L; j++) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    dp[0][0] = 1;
    for(int i = 0; i < (1 << 19); i++) {
        vector<int>res(19);
        for(int j = 0; j < 19; j++) {
            if(1 & (i >> j)) res[j] = 1;
        }
        for(int j = 18; j >= 1; j--) res[j-1] ^= res[j];
        int b = __builtin_popcount(i);
        if(b == 19) continue;
        for(int j = 0; j < A[b].size(); j++) {
            if(1 & (i >> A[b][j])) continue;
            dp[i|(1 << A[b][j])][res[A[b][j]]] += dp[i][0];
            dp[i|(1 << A[b][j])][1^res[A[b][j]]] += dp[i][1];
        }
    }
    cout << dp[(1 << 19)-1][0] << " " << dp[(1 << 19)-1][1] << endl;
}
0