結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-14 02:57:43
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,116 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 347,336 KB
最終ジャッジ日時 2024-01-16 20:57:29
合計ジャッジ時間 13,530 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 MLE -
testcase_02 MLE -
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 MLE -
testcase_28 MLE -
testcase_29 MLE -
testcase_30 MLE -
testcase_31 MLE -
testcase_32 MLE -
testcase_33 MLE -
testcase_34 MLE -
testcase_35 MLE -
testcase_36 MLE -
testcase_37 MLE -
testcase_38 MLE -
testcase_39 MLE -
testcase_40 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

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

f = [0] * (1 << N_MAX)

readline = sys.stdin.readline

n, m, k = map(int, readline().split())
s = [0] * m
for i in range(m):
    # reversed, but it's ok
    s[i] = int(readline(), 2)

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]

a = [0] * (n + 1)
for l in range(k, n + 1):
    a[l] = 1
    for i in range(k, l):
        a[l] -= a[i] * binom[l][i]

for u in s:
    f[u] += 1

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

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

b = 1
while b < n:
    for l in range(0, 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(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