結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
59,588 KB
testcase_01 AC 39 ms
59,588 KB
testcase_02 AC 51 ms
64,192 KB
testcase_03 AC 87 ms
79,500 KB
testcase_04 AC 80 ms
78,988 KB
testcase_05 AC 76 ms
78,092 KB
testcase_06 AC 98 ms
80,396 KB
testcase_07 AC 54 ms
74,124 KB
testcase_08 AC 62 ms
76,300 KB
testcase_09 AC 85 ms
78,732 KB
testcase_10 AC 72 ms
77,068 KB
testcase_11 AC 69 ms
76,556 KB
testcase_12 AC 106 ms
79,884 KB
testcase_13 AC 2,164 ms
206,768 KB
testcase_14 AC 301 ms
92,080 KB
testcase_15 AC 58 ms
68,496 KB
testcase_16 AC 119 ms
79,920 KB
testcase_17 AC 298 ms
92,080 KB
testcase_18 AC 55 ms
66,288 KB
testcase_19 AC 90 ms
77,560 KB
testcase_20 AC 55 ms
66,288 KB
testcase_21 AC 119 ms
79,920 KB
testcase_22 AC 71 ms
73,600 KB
testcase_23 AC 164 ms
82,320 KB
testcase_24 AC 147 ms
80,268 KB
testcase_25 AC 212 ms
85,392 KB
testcase_26 AC 2,520 ms
208,144 KB
testcase_27 AC 124 ms
80,016 KB
testcase_28 AC 2,258 ms
214,544 KB
testcase_29 AC 2,260 ms
213,904 KB
testcase_30 AC 2,215 ms
214,544 KB
testcase_31 AC 2,224 ms
214,544 KB
testcase_32 AC 2,229 ms
214,544 KB
testcase_33 AC 174 ms
83,216 KB
testcase_34 AC 136 ms
81,804 KB
testcase_35 AC 747 ms
113,424 KB
testcase_36 AC 40 ms
59,588 KB
testcase_37 AC 175 ms
83,888 KB
testcase_38 AC 65 ms
71,052 KB
testcase_39 AC 2,595 ms
213,648 KB
testcase_40 AC 2,588 ms
213,648 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]]

del b

# 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