結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー hotman78hotman78
提出日時 2022-12-09 07:22:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 1,000 ms
コード長 809 bytes
コンパイル時間 2,431 ms
コンパイル使用メモリ 197,880 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-22 19:01:24
合計ジャッジ時間 6,150 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
11,520 KB
testcase_01 AC 58 ms
11,392 KB
testcase_02 AC 46 ms
11,392 KB
testcase_03 AC 66 ms
11,520 KB
testcase_04 AC 65 ms
11,392 KB
testcase_05 AC 69 ms
11,392 KB
testcase_06 AC 62 ms
11,392 KB
testcase_07 AC 66 ms
11,392 KB
testcase_08 AC 63 ms
11,520 KB
testcase_09 AC 61 ms
11,392 KB
testcase_10 AC 64 ms
11,520 KB
testcase_11 AC 62 ms
11,392 KB
testcase_12 AC 62 ms
11,520 KB
testcase_13 AC 63 ms
11,392 KB
testcase_14 AC 69 ms
11,392 KB
testcase_15 AC 65 ms
11,392 KB
testcase_16 AC 61 ms
11,520 KB
testcase_17 AC 68 ms
11,392 KB
testcase_18 AC 67 ms
11,392 KB
testcase_19 AC 66 ms
11,392 KB
testcase_20 AC 60 ms
11,392 KB
testcase_21 AC 59 ms
11,520 KB
testcase_22 AC 63 ms
11,392 KB
testcase_23 AC 61 ms
11,520 KB
testcase_24 AC 66 ms
11,392 KB
testcase_25 AC 65 ms
11,392 KB
testcase_26 AC 67 ms
11,392 KB
testcase_27 AC 57 ms
11,392 KB
testcase_28 AC 50 ms
11,392 KB
testcase_29 AC 53 ms
11,520 KB
testcase_30 AC 56 ms
11,392 KB
testcase_31 AC 56 ms
11,392 KB
testcase_32 AC 57 ms
11,392 KB
testcase_33 AC 58 ms
11,392 KB
testcase_34 AC 62 ms
11,392 KB
testcase_35 AC 58 ms
11,392 KB
testcase_36 AC 59 ms
11,392 KB
testcase_37 AC 58 ms
11,392 KB
testcase_38 AC 61 ms
11,392 KB
testcase_39 AC 63 ms
11,392 KB
testcase_40 AC 63 ms
11,520 KB
testcase_41 AC 65 ms
11,392 KB
testcase_42 AC 64 ms
11,392 KB
testcase_43 AC 69 ms
11,392 KB
testcase_44 AC 68 ms
11,392 KB
testcase_45 AC 63 ms
11,520 KB
testcase_46 AC 68 ms
11,520 KB
testcase_47 AC 45 ms
11,520 KB
testcase_48 AC 67 ms
11,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
using lint=long long;

int main(){
    constexpr int n=19;
    array<int,n>l;
    array<bitset<n>,n>a;
    rep(i,n){
        a[n-1-i]=bitset<n>();
        cin>>l[n-1-i];
        rep(j,l[n-1-i]){
            int x;
            cin>>x;
            x--;
            a[n-1-i][x]=1;
        }
    }
    array<vector<lint>,2>dp;
    rep(i,2)dp[i].resize(1<<n);
    dp[0][0]=1;
    rep(d,(1<<n)-1){
        bool cnt=0;
        int k=__builtin_popcount(d);
        rep(j,n){
            if(d>>j&1){
                cnt^=1;
            }else{
                if(a[k][j]){
                    rep(t,2)dp[t^cnt][d+(1<<j)]+=dp[t][d];
                }
            }
        }
    }
    cout<<dp[0][(1<<n)-1]<<" "<<dp[1][(1<<n)-1]<<endl;
}
0