結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー 👑 rin204rin204
提出日時 2022-12-09 00:11:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 562 ms / 1,000 ms
コード長 1,229 bytes
コンパイル時間 2,655 ms
コンパイル使用メモリ 202,888 KB
実行使用メモリ 20,224 KB
最終ジャッジ日時 2024-04-22 18:46:22
合計ジャッジ時間 13,115 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,392 KB
testcase_01 AC 9 ms
11,520 KB
testcase_02 AC 7 ms
11,352 KB
testcase_03 AC 274 ms
17,792 KB
testcase_04 AC 73 ms
14,344 KB
testcase_05 AC 328 ms
19,200 KB
testcase_06 AC 68 ms
13,540 KB
testcase_07 AC 188 ms
16,128 KB
testcase_08 AC 246 ms
17,116 KB
testcase_09 AC 34 ms
12,296 KB
testcase_10 AC 265 ms
17,664 KB
testcase_11 AC 101 ms
15,644 KB
testcase_12 AC 28 ms
12,424 KB
testcase_13 AC 72 ms
14,592 KB
testcase_14 AC 174 ms
15,872 KB
testcase_15 AC 169 ms
16,480 KB
testcase_16 AC 136 ms
16,512 KB
testcase_17 AC 213 ms
17,048 KB
testcase_18 AC 273 ms
17,920 KB
testcase_19 AC 233 ms
17,580 KB
testcase_20 AC 9 ms
11,648 KB
testcase_21 AC 266 ms
17,792 KB
testcase_22 AC 82 ms
14,080 KB
testcase_23 AC 92 ms
14,336 KB
testcase_24 AC 341 ms
19,312 KB
testcase_25 AC 270 ms
18,688 KB
testcase_26 AC 199 ms
16,384 KB
testcase_27 AC 97 ms
16,384 KB
testcase_28 AC 6 ms
11,392 KB
testcase_29 AC 6 ms
11,520 KB
testcase_30 AC 5 ms
11,392 KB
testcase_31 AC 9 ms
11,520 KB
testcase_32 AC 11 ms
11,648 KB
testcase_33 AC 18 ms
12,288 KB
testcase_34 AC 42 ms
13,568 KB
testcase_35 AC 86 ms
15,288 KB
testcase_36 AC 144 ms
17,280 KB
testcase_37 AC 219 ms
19,244 KB
testcase_38 AC 303 ms
20,224 KB
testcase_39 AC 391 ms
20,076 KB
testcase_40 AC 449 ms
20,096 KB
testcase_41 AC 486 ms
19,932 KB
testcase_42 AC 479 ms
20,060 KB
testcase_43 AC 510 ms
20,096 KB
testcase_44 AC 519 ms
20,096 KB
testcase_45 AC 562 ms
20,036 KB
testcase_46 AC 543 ms
20,096 KB
testcase_47 AC 8 ms
11,264 KB
testcase_48 AC 330 ms
18,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl '\n'

int main(){
    cin.tie(0)->sync_with_stdio(0);

    int n = 19;
    vector<int> A(n, 0);
    for(int i = 0; i < n; i++){
        int l, a;
        cin >> l;
        for(int j = 0; j < l; j++){
            cin >> a;
            a--;
            A[i] |= 1 << a;
        }
    }

    set<int> se;
    se.insert(0);
    vector<ll> dp_o(1 << n, 0);
    vector<ll> dp_e(1 << n, 0);
    dp_e[0] = 1;
    for(int i = 0; i < n; i++){
        set<int> nse;
        for(auto bit:se){
            int c = 0;
            for(int j = n - 1; j >= 0; j--){
                if(bit >> j & 1) c++;
                else if(A[i] >> j & 1){
                    int nbit = bit | (1 << j);
                    nse.insert(nbit);
                    if(c & 1){
                        dp_e[nbit] += dp_o[bit];
                        dp_o[nbit] += dp_e[bit];
                    }
                    else{
                        dp_e[nbit] += dp_e[bit];
                        dp_o[nbit] += dp_o[bit];
                    }
                }
            }
        }
        swap(se, nse);
    }
    cout << dp_e[(1 << n) - 1] << " " << dp_o[(1 << n) - 1] << endl;
}
0