結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-14 02:50:16
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,690 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 351,244 KB
最終ジャッジ日時 2024-01-16 20:57:27
合計ジャッジ時間 24,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
199,664 KB
testcase_01 AC 160 ms
199,664 KB
testcase_02 AC 169 ms
204,256 KB
testcase_03 AC 215 ms
214,320 KB
testcase_04 AC 204 ms
213,276 KB
testcase_05 AC 205 ms
212,680 KB
testcase_06 AC 242 ms
215,412 KB
testcase_07 AC 194 ms
209,608 KB
testcase_08 AC 190 ms
209,996 KB
testcase_09 AC 210 ms
212,928 KB
testcase_10 AC 204 ms
210,988 KB
testcase_11 AC 195 ms
209,876 KB
testcase_12 AC 244 ms
214,448 KB
testcase_13 TLE -
testcase_14 AC 691 ms
225,228 KB
testcase_15 AC 183 ms
208,976 KB
testcase_16 AC 297 ms
212,940 KB
testcase_17 AC 693 ms
225,228 KB
testcase_18 AC 173 ms
205,160 KB
testcase_19 AC 237 ms
210,892 KB
testcase_20 AC 178 ms
205,160 KB
testcase_21 AC 305 ms
212,940 KB
testcase_22 AC 207 ms
209,996 KB
testcase_23 AC 358 ms
217,424 KB
testcase_24 AC 262 ms
214,796 KB
testcase_25 AC 405 ms
220,556 KB
testcase_26 TLE -
testcase_27 AC 266 ms
214,204 KB
testcase_28 MLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 350 ms
218,264 KB
testcase_34 AC 299 ms
216,800 KB
testcase_35 AC 1,358 ms
247,876 KB
testcase_36 AC 161 ms
199,664 KB
testcase_37 AC 422 ms
217,036 KB
testcase_38 AC 193 ms
209,484 KB
testcase_39 TLE -
testcase_40 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

from typing import List
import sys

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

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

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

def calc_f(n: int, m: int, k: int, s: List[int]):
    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]
    
    f = [0] * (1 << n)
    for u in s:
        f[u] += 1
    supset_zeta(f)
    for t in range(1 << n):
        f[t] *= a[popcnt[t]]
    subset_zeta(f)
    return f

def calc_g(n: int, m: int, f: List[int]):
    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])
    return g

if __name__ == '__main__':
    readline = sys.stdin.readline

    n, m, k = map(int, readline().split())
    s = [0] * m
    for i in range(m):
        si = readline()
        for j in range(n):
            s[i] |= (si[j] == '1') << j
    f = calc_f(n, m, k, s)
    g = calc_g(n, m, f)
    print('\n'.join(map(str, g[1:])))
0