結果

問題 No.2152 [Cherry Anniversary 2] 19 Petals of Cherry
ユーザー kotatsugamekotatsugame
提出日時 2022-12-09 21:15:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 463 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 65,432 KB
実行使用メモリ 11,852 KB
最終ジャッジ日時 2024-04-22 19:18:53
合計ジャッジ時間 4,349 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
11,592 KB
testcase_01 AC 49 ms
11,704 KB
testcase_02 AC 37 ms
6,940 KB
testcase_03 AC 53 ms
11,632 KB
testcase_04 AC 56 ms
11,660 KB
testcase_05 AC 56 ms
11,660 KB
testcase_06 AC 55 ms
11,836 KB
testcase_07 AC 55 ms
11,556 KB
testcase_08 AC 51 ms
11,504 KB
testcase_09 AC 56 ms
11,788 KB
testcase_10 AC 56 ms
11,852 KB
testcase_11 AC 56 ms
11,796 KB
testcase_12 AC 56 ms
11,740 KB
testcase_13 AC 54 ms
11,668 KB
testcase_14 AC 55 ms
11,724 KB
testcase_15 AC 57 ms
11,544 KB
testcase_16 AC 56 ms
11,524 KB
testcase_17 AC 54 ms
11,752 KB
testcase_18 AC 55 ms
11,820 KB
testcase_19 AC 57 ms
11,732 KB
testcase_20 AC 50 ms
11,656 KB
testcase_21 AC 58 ms
11,588 KB
testcase_22 AC 57 ms
11,692 KB
testcase_23 AC 54 ms
11,788 KB
testcase_24 AC 54 ms
11,548 KB
testcase_25 AC 55 ms
11,508 KB
testcase_26 AC 56 ms
11,760 KB
testcase_27 AC 51 ms
11,556 KB
testcase_28 AC 45 ms
11,776 KB
testcase_29 AC 47 ms
11,644 KB
testcase_30 AC 48 ms
11,492 KB
testcase_31 AC 48 ms
11,584 KB
testcase_32 AC 48 ms
11,472 KB
testcase_33 AC 48 ms
11,656 KB
testcase_34 AC 49 ms
11,656 KB
testcase_35 AC 50 ms
11,712 KB
testcase_36 AC 50 ms
11,736 KB
testcase_37 AC 52 ms
11,516 KB
testcase_38 AC 50 ms
11,720 KB
testcase_39 AC 55 ms
11,608 KB
testcase_40 AC 56 ms
11,672 KB
testcase_41 AC 54 ms
11,852 KB
testcase_42 AC 54 ms
11,652 KB
testcase_43 AC 53 ms
11,472 KB
testcase_44 AC 49 ms
11,728 KB
testcase_45 AC 39 ms
11,624 KB
testcase_46 AC 46 ms
11,628 KB
testcase_47 AC 37 ms
6,940 KB
testcase_48 AC 58 ms
11,848 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int A[19];
long dp[1<<19][2];
main()
{
	for(int i=0;i<19;i++)
	{
		int N;cin>>N;
		for(;N--;)
		{
			int a;cin>>a;
			A[i]|=1<<a-1;
		}
	}
	dp[0][0]=1;
	for(int i=0;i+1<1<<19;i++)
	{
		int c=__builtin_popcount(i);
		int t=0;
		for(int j=19;j--;)
		{
			if(i>>j&1)t^=1;
			else if(A[c]>>j&1)
			{
				dp[i|1<<j][t]+=dp[i][0];
				dp[i|1<<j][!t]+=dp[i][1];
			}
		}
	}
	cout<<dp[(1<<19)-1][0]<<" "<<dp[(1<<19)-1][1]<<endl;
}
0