結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-16 21:06:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,426 ms / 4,000 ms
コード長 1,144 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 214,416 KB
最終ジャッジ日時 2024-01-16 21:07:28
合計ジャッジ時間 36,821 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
59,588 KB
testcase_01 AC 42 ms
59,588 KB
testcase_02 AC 51 ms
64,192 KB
testcase_03 AC 85 ms
79,500 KB
testcase_04 AC 81 ms
78,988 KB
testcase_05 AC 75 ms
78,092 KB
testcase_06 AC 98 ms
80,396 KB
testcase_07 AC 55 ms
74,124 KB
testcase_08 AC 62 ms
76,300 KB
testcase_09 AC 83 ms
78,732 KB
testcase_10 AC 71 ms
77,068 KB
testcase_11 AC 69 ms
76,428 KB
testcase_12 AC 107 ms
79,884 KB
testcase_13 AC 3,093 ms
206,768 KB
testcase_14 AC 398 ms
92,080 KB
testcase_15 AC 57 ms
66,404 KB
testcase_16 AC 137 ms
79,920 KB
testcase_17 AC 403 ms
92,080 KB
testcase_18 AC 54 ms
66,288 KB
testcase_19 AC 95 ms
74,616 KB
testcase_20 AC 55 ms
66,288 KB
testcase_21 AC 138 ms
79,920 KB
testcase_22 AC 74 ms
71,564 KB
testcase_23 AC 166 ms
81,936 KB
testcase_24 AC 127 ms
80,268 KB
testcase_25 AC 227 ms
85,392 KB
testcase_26 AC 3,331 ms
208,016 KB
testcase_27 AC 146 ms
79,760 KB
testcase_28 AC 3,183 ms
214,416 KB
testcase_29 AC 3,184 ms
213,776 KB
testcase_30 AC 3,187 ms
214,416 KB
testcase_31 AC 3,216 ms
214,416 KB
testcase_32 AC 3,169 ms
214,416 KB
testcase_33 AC 182 ms
82,960 KB
testcase_34 AC 140 ms
81,804 KB
testcase_35 AC 908 ms
113,168 KB
testcase_36 AC 41 ms
59,588 KB
testcase_37 AC 223 ms
83,888 KB
testcase_38 AC 64 ms
68,984 KB
testcase_39 AC 3,424 ms
213,520 KB
testcase_40 AC 3,426 ms
213,520 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)]

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] = (-1) ** (l - k) * binom[l - 1][l - k]

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

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

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

g = [n + 1] * (m + 1)
for t in range(2 ** n):
    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