結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-16 21:39:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,459 ms / 4,000 ms
コード長 1,282 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 214,420 KB
最終ジャッジ日時 2024-01-16 21:40:20
合計ジャッジ時間 28,879 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,588 KB
testcase_01 AC 41 ms
59,588 KB
testcase_02 AC 54 ms
64,192 KB
testcase_03 AC 86 ms
79,504 KB
testcase_04 AC 81 ms
78,992 KB
testcase_05 AC 77 ms
78,096 KB
testcase_06 AC 101 ms
80,400 KB
testcase_07 AC 56 ms
74,256 KB
testcase_08 AC 63 ms
76,304 KB
testcase_09 AC 85 ms
78,736 KB
testcase_10 AC 72 ms
77,072 KB
testcase_11 AC 69 ms
76,432 KB
testcase_12 AC 107 ms
79,888 KB
testcase_13 AC 2,282 ms
206,764 KB
testcase_14 AC 342 ms
92,076 KB
testcase_15 AC 59 ms
68,488 KB
testcase_16 AC 122 ms
79,916 KB
testcase_17 AC 314 ms
92,076 KB
testcase_18 AC 55 ms
66,292 KB
testcase_19 AC 93 ms
77,560 KB
testcase_20 AC 55 ms
66,292 KB
testcase_21 AC 122 ms
79,916 KB
testcase_22 AC 72 ms
73,600 KB
testcase_23 AC 190 ms
82,196 KB
testcase_24 AC 123 ms
80,016 KB
testcase_25 AC 206 ms
85,268 KB
testcase_26 AC 2,363 ms
208,020 KB
testcase_27 AC 124 ms
79,892 KB
testcase_28 AC 2,453 ms
214,420 KB
testcase_29 AC 2,444 ms
213,780 KB
testcase_30 AC 2,436 ms
214,420 KB
testcase_31 AC 2,444 ms
214,420 KB
testcase_32 AC 2,427 ms
214,420 KB
testcase_33 AC 173 ms
83,092 KB
testcase_34 AC 136 ms
81,936 KB
testcase_35 AC 719 ms
113,300 KB
testcase_36 AC 41 ms
59,588 KB
testcase_37 AC 188 ms
83,884 KB
testcase_38 AC 65 ms
71,048 KB
testcase_39 AC 2,446 ms
213,524 KB
testcase_40 AC 2,459 ms
213,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

readline = sys.stdin.readline

popcnt = [0] * (2 ** 12)
for t in range(1, 2 ** 12):
    popcnt[t] = 1 + popcnt[t & (t - 1)]

MASK_20 = 2 ** 20 - 1

n, m, k = map(int, readline().split())

binom = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n + 1):
    binom[i][0] = 1
    for j in range(1, i + 1):
        binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j]

f = [0] * (2 ** n)

for i in range(m):
    # reversed, but it's ok
    s = int(readline(), 2)
    f[s] += 1

a = [0] * (n + 1)
for l in range(k, n + 1):
    a[l] = binom[l - 1][l - k]
    if a[l] and ((l - k) & 1):
        a[l] = (2 ** 20) - a[l]

# supset zeta
b1 = 1
while b1 < 2 ** n:
    for l in range(0, 2 ** n, 2 * b1):
        for p in range(l, l + b1):
            f[p] += f[p + b1]
    b1 *= 2

for t in range(2 ** n):
    f[t] &= MASK_20
    f[t] = (f[t] * a[popcnt[t >> 12] + popcnt[t & 0xfff]]) & MASK_20

# subset zeta
b2 = 1
while b2 < 2 ** n:
    for l in range(0, 2 ** n, 2 * b2):
        for p in range(l, l + b2):
            f[p + b2] += f[p]
    b2 *= 2

g = [n + 1] * (m + 1)
for t in range(2 ** n):
    f[t] &= MASK_20
    g[f[t]] = min(g[f[t]], popcnt[t >> 12] + popcnt[t & 0xfff])

for p in reversed(range(m)):
    g[p] = min(g[p], g[p + 1])

print('\n'.join(map(str, g[1:])))
0