結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-16 20:56:38
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,227 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 215,588 KB
最終ジャッジ日時 2024-01-16 21:02:20
合計ジャッジ時間 20,658 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
59,588 KB
testcase_01 AC 39 ms
59,588 KB
testcase_02 AC 46 ms
62,236 KB
testcase_03 AC 91 ms
79,500 KB
testcase_04 AC 81 ms
78,988 KB
testcase_05 AC 77 ms
78,220 KB
testcase_06 AC 99 ms
80,396 KB
testcase_07 AC 56 ms
74,252 KB
testcase_08 AC 62 ms
76,300 KB
testcase_09 AC 85 ms
78,732 KB
testcase_10 AC 74 ms
77,196 KB
testcase_11 AC 66 ms
76,300 KB
testcase_12 AC 102 ms
79,884 KB
testcase_13 TLE -
testcase_14 AC 558 ms
91,800 KB
testcase_15 AC 51 ms
68,428 KB
testcase_16 AC 169 ms
79,640 KB
testcase_17 AC 561 ms
91,800 KB
testcase_18 AC 48 ms
64,324 KB
testcase_19 AC 109 ms
77,472 KB
testcase_20 AC 48 ms
64,324 KB
testcase_21 AC 174 ms
79,640 KB
testcase_22 AC 81 ms
76,452 KB
testcase_23 AC 173 ms
81,680 KB
testcase_24 AC 118 ms
80,396 KB
testcase_25 AC 261 ms
85,392 KB
testcase_26 TLE -
testcase_27 AC 127 ms
79,632 KB
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 191 ms
82,960 KB
testcase_34 AC 129 ms
81,932 KB
testcase_35 AC 1,215 ms
113,168 KB
testcase_36 AC 39 ms
59,588 KB
testcase_37 AC 297 ms
83,608 KB
testcase_38 AC 65 ms
75,960 KB
testcase_39 TLE -
testcase_40 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N_MAX = 24
HALF_N_MAX = 12
MASK_HALF_N_MAX = (1 << 12) - 1

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 << HALF_N_MAX)
for t in range(1, 1 << HALF_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 >> HALF_N_MAX] + popcnt[t & MASK_HALF_N_MAX]]

# 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 >> HALF_N_MAX] + popcnt[t & MASK_HALF_N_MAX])

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

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