結果
問題 | No.2152 [Cherry Anniversary 2] 19 Petals of Cherry |
ユーザー | 👑 rin204 |
提出日時 | 2022-12-09 00:11:49 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 530 ms / 1,000 ms |
コード長 | 1,229 bytes |
コンパイル時間 | 2,396 ms |
コンパイル使用メモリ | 210,128 KB |
実行使用メモリ | 20,096 KB |
最終ジャッジ日時 | 2024-10-14 18:17:31 |
合計ジャッジ時間 | 12,844 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
ソースコード
#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; }