結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
59,588 KB
testcase_01 AC 39 ms
59,588 KB
testcase_02 AC 52 ms
64,192 KB
testcase_03 AC 89 ms
79,500 KB
testcase_04 AC 81 ms
78,988 KB
testcase_05 AC 77 ms
78,092 KB
testcase_06 AC 99 ms
80,396 KB
testcase_07 AC 55 ms
74,124 KB
testcase_08 AC 63 ms
76,300 KB
testcase_09 AC 86 ms
78,732 KB
testcase_10 AC 72 ms
77,068 KB
testcase_11 AC 70 ms
76,428 KB
testcase_12 AC 108 ms
80,012 KB
testcase_13 AC 2,148 ms
206,768 KB
testcase_14 AC 300 ms
92,080 KB
testcase_15 AC 58 ms
68,496 KB
testcase_16 AC 118 ms
79,920 KB
testcase_17 AC 302 ms
92,080 KB
testcase_18 AC 54 ms
66,288 KB
testcase_19 AC 89 ms
77,688 KB
testcase_20 AC 55 ms
66,288 KB
testcase_21 AC 118 ms
79,920 KB
testcase_22 AC 71 ms
73,600 KB
testcase_23 AC 165 ms
82,192 KB
testcase_24 AC 120 ms
80,140 KB
testcase_25 AC 212 ms
85,264 KB
testcase_26 AC 2,515 ms
208,016 KB
testcase_27 AC 124 ms
79,888 KB
testcase_28 AC 2,259 ms
214,416 KB
testcase_29 AC 2,243 ms
213,776 KB
testcase_30 AC 2,246 ms
214,416 KB
testcase_31 AC 2,234 ms
214,416 KB
testcase_32 AC 2,227 ms
214,416 KB
testcase_33 AC 174 ms
83,088 KB
testcase_34 AC 134 ms
81,676 KB
testcase_35 AC 727 ms
113,296 KB
testcase_36 AC 40 ms
59,588 KB
testcase_37 AC 175 ms
83,888 KB
testcase_38 AC 64 ms
71,056 KB
testcase_39 AC 2,593 ms
213,520 KB
testcase_40 AC 2,601 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
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] *= a[popcnt[t >> 12] + popcnt[t & 0xfff]]

# 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):
    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