結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー hotman78
提出日時 2022-12-09 07:19:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 787 bytes
コンパイル時間 2,162 ms
コンパイル使用メモリ 193,948 KB
最終ジャッジ日時 2025-02-09 06:46:32
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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<array<int,(1<<n)>,2>dp;
    rep(i,2)dp[i].fill(0);
    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