結果

問題 No.1189 Sum is XOR
ユーザー kotatsugamekotatsugame
提出日時 2020-08-22 16:20:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 594 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 66,280 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 10:30:36
合計ジャッジ時間 1,667 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 7 ms
6,940 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N,K;
long dp[11][1<<10];
long cnt[1<<10];
const long mod=998244353;
main()
{
	cin>>N>>K;
	if(K>10)
	{
		cout<<0<<endl;
		return 0;
	}
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;
		cnt[A]++;
	}
	for(int i=1<<10;i--;)
	{
		int T=i&-i;
		for(int j=1;j<T;j++)cnt[i|j]+=cnt[i];
	}
	dp[0][0]=1;
	for(int k=0;k<K;k++)
	{
		for(int i=0;i<1<<10;i++)
		{
			int T=1023&~i;
			int lim=T&-T;
			for(int j=T;j>0;j=j-1&T)
			{
				if(j&lim)(dp[k+1][i|j]+=dp[k][i]*cnt[j])%=mod;
			}
		}
	}
	long ans=0;
	for(int i=0;i<1<<10;i++)ans+=dp[K][i];
	cout<<ans%mod<<endl;
}
0