結果

問題 No.1189 Sum is XOR
ユーザー nebocconebocco
提出日時 2020-08-22 15:38:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 680 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 28,856 KB
最終ジャッジ日時 2024-04-23 09:57:54
合計ジャッジ時間 12,407 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 71 ms
19,264 KB
testcase_04 AC 64 ms
18,124 KB
testcase_05 AC 87 ms
23,024 KB
testcase_06 AC 113 ms
28,724 KB
testcase_07 AC 76 ms
20,592 KB
testcase_08 AC 50 ms
15,100 KB
testcase_09 AC 50 ms
15,104 KB
testcase_10 AC 48 ms
14,080 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 31 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
a = list(map(int, input().split()))

g = [0] * 1024

for x in a: g[x] += 1

def gen(x, n, l):
    if bin(x).count('1') < n:
        yield list()
    elif n == 0:
        yield l
    else:
        y = x
        while y:
            if g[y] > 0:
                yield from gen(x ^ y, n - 1, l + [y])
            y = (y - 1) & x
            if l and y < l[-1]:
                break

ans = 0
mod = 998244353

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

for l in gen(1023, k, list()):
    if not l: continue
    # print(l)
    cur = 1
    for x in l:
        cur = cur * g[x] % mod
    # if cur:
    #     print(l, cur)
    ans = (ans + cur) % mod
print(ans)
0