結果

問題 No.1189 Sum is XOR
ユーザー 沙耶花沙耶花
提出日時 2020-08-22 13:37:45
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 2,355 ms
コンパイル使用メモリ 201,264 KB
実行使用メモリ 93,568 KB
最終ジャッジ日時 2024-04-23 08:03:12
合計ジャッジ時間 5,682 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
77,184 KB
testcase_01 AC 150 ms
60,672 KB
testcase_02 AC 149 ms
60,800 KB
testcase_03 AC 22 ms
5,376 KB
testcase_04 AC 19 ms
5,376 KB
testcase_05 AC 30 ms
5,376 KB
testcase_06 AC 44 ms
5,376 KB
testcase_07 AC 25 ms
5,376 KB
testcase_08 AC 12 ms
5,376 KB
testcase_09 AC 12 ms
5,376 KB
testcase_10 AC 9 ms
5,376 KB
testcase_11 AC 118 ms
60,672 KB
testcase_12 AC 147 ms
60,800 KB
testcase_13 AC 165 ms
77,184 KB
testcase_14 AC 150 ms
77,184 KB
testcase_15 AC 135 ms
77,184 KB
testcase_16 AC 151 ms
93,568 KB
testcase_17 AC 133 ms
77,184 KB
testcase_18 AC 122 ms
60,672 KB
testcase_19 AC 157 ms
77,312 KB
testcase_20 AC 160 ms
77,184 KB
testcase_21 AC 104 ms
60,672 KB
testcase_22 AC 102 ms
60,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 2000000005

int main(){
	
	int N,K;
	cin>>N>>K;
	
	vector<int> c(1024,0);
	for(int i=0;i<N;i++){
		int t;
		cin>>t;
		c[t]++;
	}
	
	if(K>11){
		cout<<0<<endl;
		return 0;
	}
	
	vector dp(1025,vector(1024,vector<int>(K+1,0)));
	dp[0][0][0] = 1;
	
	for(int i=0;i<1024;i++){
		for(int j=0;j<1024;j++){
			for(int k=0;k<=K;k++){
				if(dp[i][j][k]==0)continue;
				dp[i+1][j][k] = mod(dp[i][j][k]+dp[i+1][j][k]);
				if(k==K)continue;
				if(j&i)continue;
				dp[i+1][j^i][k+1] = mod(dp[i+1][j^i][k+1] + mod(dp[i][j][k]*c[i]));
				
			}
		}
	}
	
	int ans = 0;
	for(int i=0;i<1024;i++){
		ans = mod(ans + dp.back()[i][K]);
	}
	
	cout<<ans<<endl;
	
	return 0;
}
0