結果

問題 No.1189 Sum is XOR
ユーザー tktk_snsn
提出日時 2021-01-16 12:04:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 105,088 KB
最終ジャッジ日時 2024-11-27 12:04:51
合計ジャッジ時間 4,306 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
U = 1 << 10

B = Counter(A)
if len(B) < K:
    print(0)
    exit()

dp = [[0] * (U + 1) for _ in range(K + 1)]
dp[0][0] = 1
cnt = 1
for a, val in B.items():
    for i in reversed(range(1, cnt + 1)):
        for j in range(U):
            if a & j:
                continue
            dp[i][a + j] += dp[i - 1][j] * val
            dp[i][a + j] %= mod
    cnt += 1
    cnt = min(K, cnt)

print(sum(dp[K]) % mod)
0