結果

問題 No.1189 Sum is XOR
ユーザー mkawa2mkawa2
提出日時 2021-07-14 22:14:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 155 ms / 2,000 ms
コード長 1,144 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 105,624 KB
最終ジャッジ日時 2023-09-17 00:38:50
合計ジャッジ時間 4,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
105,496 KB
testcase_01 AC 142 ms
105,624 KB
testcase_02 AC 126 ms
105,492 KB
testcase_03 AC 84 ms
89,008 KB
testcase_04 AC 80 ms
87,204 KB
testcase_05 AC 89 ms
95,344 KB
testcase_06 AC 99 ms
104,628 KB
testcase_07 AC 83 ms
91,120 KB
testcase_08 AC 72 ms
80,644 KB
testcase_09 AC 77 ms
81,396 KB
testcase_10 AC 73 ms
79,172 KB
testcase_11 AC 111 ms
80,572 KB
testcase_12 AC 128 ms
105,220 KB
testcase_13 AC 148 ms
102,012 KB
testcase_14 AC 134 ms
91,396 KB
testcase_15 AC 129 ms
80,456 KB
testcase_16 AC 139 ms
77,776 KB
testcase_17 AC 117 ms
79,932 KB
testcase_18 AC 109 ms
85,032 KB
testcase_19 AC 149 ms
96,536 KB
testcase_20 AC 154 ms
96,384 KB
testcase_21 AC 67 ms
76,084 KB
testcase_22 AC 68 ms
75,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

n, k = LI()
aa = LI()
cnt = [0]*1024
for a in aa: cnt[a] += 1

if k > 10:
    print(0)
    exit()

def add(i, j, val):
    dp[i][j] = (dp[i][j]+val)%md

dp = [[0]*(1 << 10) for _ in range(k+1)]
dp[0][0] = 1
for a in range(1 << 10):
    if cnt[a] == 0: continue
    for i in range(k):
        for s in range(1 << 10):
            if s & a: continue
            pre = dp[i][s]
            if pre == 0: continue
            add(i+1, s | a, pre*cnt[a])

ans = 0
for s in range(1 << 10):
    ans += dp[k][s]
    ans %= md
print(ans)
0