結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー norikamenorikame
提出日時 2022-12-09 19:49:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 1,000 ms
コード長 933 bytes
コンパイル時間 4,851 ms
コンパイル使用メモリ 255,572 KB
実行使用メモリ 32,068 KB
最終ジャッジ日時 2024-04-22 19:15:43
合計ジャッジ時間 9,871 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
32,068 KB
testcase_01 AC 73 ms
31,984 KB
testcase_02 AC 51 ms
31,968 KB
testcase_03 AC 95 ms
31,904 KB
testcase_04 AC 86 ms
32,016 KB
testcase_05 AC 96 ms
32,068 KB
testcase_06 AC 89 ms
31,872 KB
testcase_07 AC 93 ms
31,928 KB
testcase_08 AC 87 ms
31,872 KB
testcase_09 AC 84 ms
32,032 KB
testcase_10 AC 84 ms
31,872 KB
testcase_11 AC 84 ms
32,008 KB
testcase_12 AC 90 ms
31,872 KB
testcase_13 AC 84 ms
31,988 KB
testcase_14 AC 97 ms
31,936 KB
testcase_15 AC 96 ms
31,868 KB
testcase_16 AC 84 ms
31,940 KB
testcase_17 AC 88 ms
31,976 KB
testcase_18 AC 95 ms
31,988 KB
testcase_19 AC 93 ms
31,952 KB
testcase_20 AC 76 ms
31,972 KB
testcase_21 AC 84 ms
31,956 KB
testcase_22 AC 91 ms
31,868 KB
testcase_23 AC 82 ms
31,872 KB
testcase_24 AC 96 ms
31,836 KB
testcase_25 AC 90 ms
31,872 KB
testcase_26 AC 93 ms
32,000 KB
testcase_27 AC 74 ms
31,868 KB
testcase_28 AC 63 ms
31,972 KB
testcase_29 AC 63 ms
31,872 KB
testcase_30 AC 64 ms
32,000 KB
testcase_31 AC 65 ms
31,932 KB
testcase_32 AC 66 ms
31,932 KB
testcase_33 AC 66 ms
31,872 KB
testcase_34 AC 67 ms
31,872 KB
testcase_35 AC 67 ms
32,000 KB
testcase_36 AC 72 ms
31,956 KB
testcase_37 AC 71 ms
31,872 KB
testcase_38 AC 72 ms
31,860 KB
testcase_39 AC 75 ms
31,980 KB
testcase_40 AC 79 ms
32,000 KB
testcase_41 AC 86 ms
31,872 KB
testcase_42 AC 92 ms
31,872 KB
testcase_43 AC 97 ms
31,872 KB
testcase_44 AC 100 ms
32,000 KB
testcase_45 AC 94 ms
31,984 KB
testcase_46 AC 99 ms
31,872 KB
testcase_47 AC 51 ms
31,872 KB
testcase_48 AC 96 ms
31,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const int INF = (int)(1e9);

int main() {
	int n = 19;
	vector<int> a(n);
	rep(i, n) {
		int li;
		cin >> li;
		rep(j, li) {
			int ai;
			cin >> ai;
			--ai;
			a[i] |= 1 << ai;
		}
	}
	vector<vector<ll>> dp(1<<n, vector<ll>(2));
	dp[0][0] = 1;
	rep(i, (1<<n)-1) {
		int bi = __builtin_popcount(i);
		rep(j, n) if ((a[bi]&(1<<j)) && !(i&(1<<j))) {
			int add = __builtin_popcount(i&(-(1<<(j+1)))) % 2;
			rep(j2, 2) dp[i|(1<<j)][(j2+add)%2] += dp[i][j2];
		}
	}
	cout << dp[(1<<n)-1][0] << ' ' << dp[(1<<n)-1][1] << endl;
	return 0;
}
0