結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-14 03:39:21
言語 PyPy3
(7.3.15)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,538 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 345,608 KB
最終ジャッジ日時 2024-01-16 20:59:21
合計ジャッジ時間 40,946 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
190,644 KB
testcase_01 AC 138 ms
190,644 KB
testcase_02 AC 159 ms
195,268 KB
testcase_03 AC 187 ms
210,580 KB
testcase_04 AC 183 ms
210,068 KB
testcase_05 AC 177 ms
209,172 KB
testcase_06 AC 199 ms
211,476 KB
testcase_07 AC 155 ms
205,332 KB
testcase_08 AC 169 ms
207,380 KB
testcase_09 AC 186 ms
209,812 KB
testcase_10 AC 172 ms
208,148 KB
testcase_11 AC 170 ms
207,508 KB
testcase_12 AC 209 ms
210,964 KB
testcase_13 MLE -
testcase_14 AC 499 ms
223,156 KB
testcase_15 AC 162 ms
197,480 KB
testcase_16 AC 247 ms
210,996 KB
testcase_17 AC 500 ms
223,156 KB
testcase_18 AC 153 ms
197,360 KB
testcase_19 AC 195 ms
205,688 KB
testcase_20 AC 155 ms
197,360 KB
testcase_21 AC 239 ms
210,996 KB
testcase_22 AC 175 ms
200,544 KB
testcase_23 AC 267 ms
213,016 KB
testcase_24 AC 217 ms
211,348 KB
testcase_25 AC 332 ms
216,472 KB
testcase_26 MLE -
testcase_27 AC 226 ms
210,968 KB
testcase_28 MLE -
testcase_29 MLE -
testcase_30 MLE -
testcase_31 MLE -
testcase_32 MLE -
testcase_33 AC 279 ms
214,040 KB
testcase_34 AC 236 ms
212,884 KB
testcase_35 AC 968 ms
244,248 KB
testcase_36 AC 140 ms
190,644 KB
testcase_37 AC 323 ms
214,836 KB
testcase_38 AC 165 ms
200,064 KB
testcase_39 MLE -
testcase_40 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from time import perf_counter

start = perf_counter()

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)]

print(perf_counter() - start, file=sys.stderr)

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]

print(perf_counter() - start, file=sys.stderr)

# 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

print(perf_counter() - start, file=sys.stderr)

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

print(perf_counter() - start, file=sys.stderr)

f.reverse()

# subset 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

f.reverse()

print(perf_counter() - start, file=sys.stderr)

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(perf_counter() - start, file=sys.stderr)

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

print(perf_counter() - start, file=sys.stderr)
0