結果

問題 No.1189 Sum is XOR
ユーザー ああいいああいい
提出日時 2022-01-29 20:13:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 390 ms / 2,000 ms
コード長 583 bytes
コンパイル時間 717 ms
コンパイル使用メモリ 86,828 KB
実行使用メモリ 168,824 KB
最終ジャッジ日時 2023-08-30 19:47:00
合計ジャッジ時間 7,836 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 345 ms
145,512 KB
testcase_01 AC 264 ms
121,036 KB
testcase_02 AC 229 ms
108,296 KB
testcase_03 AC 91 ms
88,924 KB
testcase_04 AC 88 ms
87,292 KB
testcase_05 AC 96 ms
95,344 KB
testcase_06 AC 107 ms
104,828 KB
testcase_07 AC 91 ms
90,964 KB
testcase_08 AC 81 ms
80,164 KB
testcase_09 AC 82 ms
80,876 KB
testcase_10 AC 80 ms
78,740 KB
testcase_11 AC 265 ms
127,832 KB
testcase_12 AC 227 ms
108,276 KB
testcase_13 AC 337 ms
145,484 KB
testcase_14 AC 329 ms
144,520 KB
testcase_15 AC 342 ms
152,640 KB
testcase_16 AC 390 ms
168,824 KB
testcase_17 AC 283 ms
132,152 KB
testcase_18 AC 231 ms
107,620 KB
testcase_19 AC 337 ms
145,008 KB
testcase_20 AC 381 ms
151,188 KB
testcase_21 AC 165 ms
90,824 KB
testcase_22 AC 165 ms
90,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
A = list(map(int,input().split()))
P = 998244353

import sys
if K > 10:
    print(0)
    exit()

C = 2 ** 10
dp = [[[0] * C for _ in range(K+1)] for _ in range(C)]
dat = [0] * C
dp[0][0][0] = 1
for a in A:
    dat[a] += 1
for bit in range(C-1):
    for k in range(K+1):
        for S in range(C):
            dp[bit + 1][k][S] += dp[bit][k][S]
            if (bit+1) & S == 0 and k < K:
                dp[bit + 1][k+1][S | (bit+1)] += dp[bit][k][S] * dat[bit+1] % P
                dp[bit+1][k+1][S | (bit+1)] %= P
ans = sum(dp[-1][K]) % P
print(ans)
0