結果

問題 No.1689 Set Cards
ユーザー publflpublfl
提出日時 2021-09-24 22:04:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 34,396 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-18 21:22:56
合計ジャッジ時間 1,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 6 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#define MOD 998244353

long long int power(long long int a, long long int b)
{
	long long int ans = 1;
	long long int k = a;
	while(b)
	{
		if(b%2==1) ans*=k, ans%=MOD;
		b/=2;
		k*=k, k%=MOD;
	}
	return ans;
}

int x[110];
int count[1000010];
void func(int k, int sum)
{
	if(k==0)
	{
		count[sum]++;
		return;
	}
	
	func(k-1,sum);
	func(k-1,sum+(1<<(x[k]-1)));
}

int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a;i++)
	{
		int b;
		scanf("%d",&b);
		for(int j=1;j<=b;j++)
		{
			int c;
			scanf("%d",&c);
			x[j] = c;
		}
		func(b,0);
	}
	
	long long int ans = 0;
	for(int i=0;i<(1<<12);i++)
	{
		int t = i;
		int s = 0;
		while(t)
		{
			if(t%2==1) s++;
			t/=2;
		}
		if(s%2==0) ans += (MOD-power(2,count[i])), ans %= MOD;
		else ans += power(2,count[i]), ans %= MOD;
	}
	
	printf("%lld",(MOD+MOD-ans)%MOD);
}
0