結果

問題 No.1189 Sum is XOR
ユーザー roarisroaris
提出日時 2020-08-22 16:08:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 559 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 245,088 KB
最終ジャッジ日時 2023-08-05 13:09:52
合計ジャッジ時間 9,195 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 487 ms
220,068 KB
testcase_01 AC 409 ms
195,344 KB
testcase_02 AC 392 ms
187,004 KB
testcase_03 AC 112 ms
89,372 KB
testcase_04 AC 111 ms
87,800 KB
testcase_05 AC 120 ms
95,844 KB
testcase_06 AC 132 ms
104,992 KB
testcase_07 AC 115 ms
91,324 KB
testcase_08 AC 103 ms
80,708 KB
testcase_09 AC 103 ms
81,804 KB
testcase_10 AC 100 ms
79,708 KB
testcase_11 AC 409 ms
204,360 KB
testcase_12 AC 387 ms
186,772 KB
testcase_13 AC 490 ms
220,036 KB
testcase_14 AC 471 ms
219,592 KB
testcase_15 AC 486 ms
229,860 KB
testcase_16 AC 556 ms
245,088 KB
testcase_17 AC 429 ms
212,320 KB
testcase_18 AC 439 ms
197,216 KB
testcase_19 AC 559 ms
219,552 KB
testcase_20 AC 540 ms
236,484 KB
testcase_21 AC 119 ms
77,656 KB
testcase_22 AC 115 ms
77,660 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