結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー AngrySadEightAngrySadEight
提出日時 2022-12-05 02:13:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 1,312 bytes
コンパイル時間 925 ms
コンパイル使用メモリ 76,416 KB
実行使用メモリ 11,564 KB
最終ジャッジ日時 2024-04-22 18:35:01
合計ジャッジ時間 5,916 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
11,392 KB
testcase_01 AC 67 ms
11,392 KB
testcase_02 AC 50 ms
11,480 KB
testcase_03 AC 78 ms
11,520 KB
testcase_04 AC 79 ms
11,472 KB
testcase_05 AC 79 ms
11,392 KB
testcase_06 AC 80 ms
11,564 KB
testcase_07 AC 77 ms
11,392 KB
testcase_08 AC 74 ms
11,548 KB
testcase_09 AC 70 ms
11,520 KB
testcase_10 AC 78 ms
11,520 KB
testcase_11 AC 78 ms
11,392 KB
testcase_12 AC 72 ms
11,392 KB
testcase_13 AC 76 ms
11,436 KB
testcase_14 AC 78 ms
11,520 KB
testcase_15 AC 77 ms
11,476 KB
testcase_16 AC 75 ms
11,520 KB
testcase_17 AC 78 ms
11,392 KB
testcase_18 AC 79 ms
11,520 KB
testcase_19 AC 77 ms
11,392 KB
testcase_20 AC 72 ms
11,400 KB
testcase_21 AC 74 ms
11,392 KB
testcase_22 AC 76 ms
11,392 KB
testcase_23 AC 72 ms
11,392 KB
testcase_24 AC 79 ms
11,492 KB
testcase_25 AC 78 ms
11,492 KB
testcase_26 AC 77 ms
11,392 KB
testcase_27 AC 75 ms
11,392 KB
testcase_28 AC 55 ms
11,520 KB
testcase_29 AC 59 ms
11,472 KB
testcase_30 AC 62 ms
11,372 KB
testcase_31 AC 64 ms
11,496 KB
testcase_32 AC 66 ms
11,520 KB
testcase_33 AC 67 ms
11,352 KB
testcase_34 AC 68 ms
11,392 KB
testcase_35 AC 70 ms
11,268 KB
testcase_36 AC 71 ms
11,440 KB
testcase_37 AC 73 ms
11,392 KB
testcase_38 AC 74 ms
11,460 KB
testcase_39 AC 76 ms
11,404 KB
testcase_40 AC 78 ms
11,392 KB
testcase_41 AC 80 ms
11,372 KB
testcase_42 AC 80 ms
11,460 KB
testcase_43 AC 81 ms
11,520 KB
testcase_44 AC 80 ms
11,520 KB
testcase_45 AC 69 ms
11,392 KB
testcase_46 AC 76 ms
11,392 KB
testcase_47 AC 49 ms
11,472 KB
testcase_48 AC 79 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    vector<ll> L(19);
    vector<ll> A(19, 0);
    for (ll i = 0; i < 19; i++){
        cin >> L[i];
        for (ll j = 0; j < L[i]; j++){
            ll a;
            cin >> a;
            A[i] += (1LL << (a - 1));
        }
    }
    /*for (ll i = 0; i < 19; i++){
        cout << A[i] << " ";
    }
    cout << endl;*/

    vector<ll> dp1((1 << 19), 0);//奇数
    vector<ll> dp2((1 << 19), 0);//偶数
    dp2[0] = 1;
    for (ll i = 0; i < (1 << 19) - 1; i++){
        ll popcnt1 = __builtin_popcount(i);
        for (ll j = 0; j < 19; j++){
            if ((i >> j) & 1){
                continue;
            }
            if ((A[j] >> popcnt1) & 1){
                ll bitmask = (1 << (j + 1)) - 1;
                bitmask = bitmask ^ ((1 << 19) - 1);
                ll popcnt2 = __builtin_popcount(bitmask & i);
                if (popcnt2 % 2 == 1){
                    dp1[i | (1 << j)] += dp2[i];
                    dp2[i | (1 << j)] += dp1[i];
                }
                else{
                    dp1[i | (1 << j)] += dp1[i];
                    dp2[i | (1 << j)] += dp2[i];
                }
            }
        }
    }
    cout << dp2[(1 << 19) - 1] << " " << dp1[(1 << 19) - 1] << endl;
}
0