結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-14 03:43:55
言語 PyPy2
(7.3.15)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,081 bytes
コンパイル時間 1,148 ms
コンパイル使用メモリ 76,916 KB
実行使用メモリ 347,076 KB
最終ジャッジ日時 2024-01-16 20:59:05
合計ジャッジ時間 10,636 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 177 ms
208,128 KB
testcase_01 AC 177 ms
208,128 KB
testcase_02 AC 183 ms
209,536 KB
testcase_03 AC 214 ms
215,040 KB
testcase_04 AC 213 ms
217,984 KB
testcase_05 AC 206 ms
212,864 KB
testcase_06 AC 227 ms
215,680 KB
testcase_07 AC 191 ms
210,304 KB
testcase_08 AC 192 ms
210,944 KB
testcase_09 AC 214 ms
216,960 KB
testcase_10 AC 205 ms
211,712 KB
testcase_11 AC 195 ms
210,688 KB
testcase_12 AC 225 ms
214,784 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N_MAX = 24

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

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

readline = sys.stdin.readline

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

f = [0] * (1 << 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
def supset_zeta():
    b = 1
    while b < 1 << n:
        for l in range(0, 1 << n, 2 * b):
            for p in range(l, l + b):
                f[p] += f[p + b]
        b *= 2
supset_zeta()

for t in range(1 << n):
    f[t] *= a[popcnt[t]]

# subset zeta
f.reverse()
supset_zeta()
f.reverse()

g = [n + 1] * (m + 1)
for t in range(1 << n):
    g[f[t]] = min(g[f[t]], popcnt[t])

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

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