結果

問題 No.1189 Sum is XOR
ユーザー leaf_1415leaf_1415
提出日時 2020-08-22 14:09:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 1,413 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 79,248 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 08:32:55
合計ジャッジ時間 1,919 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
6,812 KB
testcase_01 AC 31 ms
6,940 KB
testcase_02 AC 30 ms
6,940 KB
testcase_03 AC 8 ms
6,940 KB
testcase_04 AC 8 ms
6,944 KB
testcase_05 AC 11 ms
6,940 KB
testcase_06 AC 16 ms
6,944 KB
testcase_07 AC 10 ms
6,944 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 4 ms
6,944 KB
testcase_11 AC 22 ms
6,940 KB
testcase_12 AC 30 ms
6,944 KB
testcase_13 AC 35 ms
6,944 KB
testcase_14 AC 31 ms
6,944 KB
testcase_15 AC 28 ms
6,940 KB
testcase_16 AC 31 ms
6,940 KB
testcase_17 AC 24 ms
6,944 KB
testcase_18 AC 21 ms
6,940 KB
testcase_19 AC 33 ms
6,940 KB
testcase_20 AC 37 ms
6,940 KB
testcase_21 AC 13 ms
6,940 KB
testcase_22 AC 13 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 998244353

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
llint a[200005], cnt[1<<10];
llint dp[2][1<<10][11];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
		
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cnt[a[i]]++;
	
	if(m > 10){
		cout << 0 << endl;
		return 0;
	}
	
	
	llint M = 1<<10;
	dp[0][0][0] = 1;
	for(int i = 0; i < M-1; i++){
		for(int j = 0; j < M; j++){
			for(int k = 0; k <= m; k++){
				dp[(i+1)%2][j][k] = 0;
			}
		}
		for(int j = 0; j < M; j++){
			for(int k = 0; k <= m; k++){
				(dp[(i+1)%2][j][k] += dp[i%2][j][k]) %= mod;
				if(((i+1) & j) == 0 && k+1 <= m) (dp[(i+1)%2][j|(i+1)][k+1] += dp[i%2][j][k] * cnt[i+1] % mod) %= mod;
			}
		}
	}
	
	llint ans = 0;
	for(int i = 0; i < M; i++) ans += dp[(M-1)%2][i][m], ans %= mod;
	cout << ans << endl;
	
	return 0;
}
0