結果

問題 No.1189 Sum is XOR
ユーザー roarisroaris
提出日時 2020-08-22 16:08:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 468 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 243,328 KB
最終ジャッジ日時 2024-04-23 10:22:00
合計ジャッジ時間 6,894 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 406 ms
219,364 KB
testcase_01 AC 332 ms
194,848 KB
testcase_02 AC 308 ms
186,468 KB
testcase_03 AC 54 ms
78,848 KB
testcase_04 AC 51 ms
76,672 KB
testcase_05 AC 59 ms
86,912 KB
testcase_06 AC 71 ms
99,072 KB
testcase_07 AC 55 ms
81,152 KB
testcase_08 AC 47 ms
67,968 KB
testcase_09 AC 44 ms
69,248 KB
testcase_10 AC 44 ms
66,432 KB
testcase_11 AC 328 ms
201,472 KB
testcase_12 AC 306 ms
186,444 KB
testcase_13 AC 389 ms
217,864 KB
testcase_14 AC 391 ms
218,100 KB
testcase_15 AC 385 ms
226,976 KB
testcase_16 AC 431 ms
243,328 KB
testcase_17 AC 339 ms
209,872 KB
testcase_18 AC 355 ms
193,464 KB
testcase_19 AC 468 ms
217,924 KB
testcase_20 AC 436 ms
234,580 KB
testcase_21 AC 59 ms
70,272 KB
testcase_22 AC 58 ms
69,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

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

if K>10:
    print(0)
    exit()
    
cnt = Counter(A)
A = list(set(A))
dp = [[[0]*(K+1) for _ in range(1024)] for _ in range(len(A)+1)]
dp[0][0][0] = 1
MOD = 998244353

for i in range(len(A)):
    for j in range(1024):
        for k in range(K+1):
            dp[i+1][j][k] += dp[i][j][k]
            
            if j&A[i]==0 and k+1<=K:
                dp[i+1][j^A[i]][k+1] += cnt[A[i]]*dp[i][j][k]
                dp[i+1][j^A[i]][k+1] %= MOD

ans = 0

for i in range(1024):
    ans += dp[-1][i][K]
    ans %= MOD

print(ans)
0