結果

問題 No.1189 Sum is XOR
ユーザー ayaoniayaoni
提出日時 2020-12-11 10:31:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,080 bytes
コンパイル時間 268 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 103,196 KB
最終ジャッジ日時 2023-10-20 01:25:11
合計ジャッジ時間 4,207 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 55 ms
78,688 KB
testcase_04 AC 52 ms
74,860 KB
testcase_05 AC 63 ms
87,352 KB
testcase_06 AC 74 ms
98,880 KB
testcase_07 AC 58 ms
80,684 KB
testcase_08 AC 46 ms
68,064 KB
testcase_09 AC 47 ms
68,828 KB
testcase_10 AC 45 ms
66,660 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 60 ms
67,292 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 49 ms
61,872 KB
testcase_22 AC 49 ms
61,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N,K = MI()
A = LI()
mod = 998244353

if K >= 11:
    print(0)
    exit()

count = [0]*1024
for a in A:
    count[a] += 1

dp = [[0]*1024 for _ in range(K+1)]
# dp[i][j] = 和集合がjに含まれるような、i個の数字の選び方

for j in range(1024):
    k = j
    while k:
        dp[0][j] += count[k]
        k = (k-1) & j
    dp[0][j] += 1

for i in range(1,K+1):
    for j in range(1,1024):
        k = j
        while k:
            dp[i][j] += dp[i-1][j^k]*count[k]
            dp[i][j] %= mod
            k = (k-1) & j

x = 1
for i in range(2,K+1):
    x *= i

ans = dp[-1][-1]*pow(x,mod-2,mod)
print(ans % mod)
0