結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-16 21:26:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,466 ms / 4,000 ms
コード長 1,205 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 214,420 KB
最終ジャッジ日時 2024-01-16 21:26:46
合計ジャッジ時間 16,940 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
59,588 KB
testcase_01 AC 40 ms
59,588 KB
testcase_02 AC 51 ms
64,196 KB
testcase_03 AC 87 ms
79,504 KB
testcase_04 AC 81 ms
78,992 KB
testcase_05 AC 77 ms
78,096 KB
testcase_06 AC 100 ms
80,400 KB
testcase_07 AC 55 ms
74,128 KB
testcase_08 AC 63 ms
76,304 KB
testcase_09 AC 86 ms
78,736 KB
testcase_10 AC 71 ms
77,072 KB
testcase_11 AC 69 ms
76,432 KB
testcase_12 AC 107 ms
79,888 KB
testcase_13 AC 3,090 ms
206,768 KB
testcase_14 AC 403 ms
92,080 KB
testcase_15 AC 58 ms
66,408 KB
testcase_16 AC 139 ms
79,920 KB
testcase_17 AC 403 ms
92,080 KB
testcase_18 AC 55 ms
66,296 KB
testcase_19 AC 95 ms
74,620 KB
testcase_20 AC 55 ms
66,296 KB
testcase_21 AC 139 ms
79,920 KB
testcase_22 AC 74 ms
71,568 KB
testcase_23 AC 191 ms
81,940 KB
testcase_24 AC 119 ms
80,272 KB
testcase_25 AC 224 ms
85,396 KB
testcase_26 AC 3,195 ms
208,020 KB
testcase_27 AC 126 ms
79,892 KB
testcase_28 AC 3,438 ms
214,420 KB
testcase_29 AC 3,444 ms
213,780 KB
testcase_30 AC 3,466 ms
214,420 KB
testcase_31 AC 3,463 ms
214,420 KB
testcase_32 AC 3,439 ms
214,420 KB
testcase_33 AC 183 ms
82,964 KB
testcase_34 AC 134 ms
81,808 KB
testcase_35 AC 893 ms
113,172 KB
testcase_36 AC 39 ms
59,588 KB
testcase_37 AC 221 ms
83,888 KB
testcase_38 AC 64 ms
68,988 KB
testcase_39 AC 3,268 ms
213,524 KB
testcase_40 AC 3,250 ms
213,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

readline = sys.stdin.readline

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

MASK_32 = 2 ** 32 - 1

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

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]

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

for t in range(2 ** n):
    f[t] = (f[t] * a[popcnt[t >> 12] + popcnt[t & 0xfff]]) & MASK_32

# subset zeta
b = 1
while b < 2 ** n:
    for l in range(0, 2 ** 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(2 ** n):
    f[t] &= MASK_32
    g[f[t]] = min(g[f[t]], popcnt[t >> 12] + popcnt[t & 0xfff])

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

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