結果

問題 No.2669 Generalized Hitting Set
ユーザー 👑 rin204rin204
提出日時 2024-04-01 23:18:16
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,129 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 347,844 KB
最終ジャッジ日時 2024-04-01 23:19:05
合計ジャッジ時間 23,893 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 48 ms
64,188 KB
testcase_03 AC 101 ms
81,668 KB
testcase_04 AC 94 ms
80,516 KB
testcase_05 AC 88 ms
79,620 KB
testcase_06 AC 115 ms
82,820 KB
testcase_07 AC 64 ms
76,544 KB
testcase_08 AC 68 ms
77,060 KB
testcase_09 AC 97 ms
80,132 KB
testcase_10 AC 81 ms
77,956 KB
testcase_11 AC 72 ms
76,932 KB
testcase_12 AC 119 ms
81,412 KB
testcase_13 TLE -
testcase_14 AC 506 ms
108,344 KB
testcase_15 AC 57 ms
66,396 KB
testcase_16 AC 165 ms
83,768 KB
testcase_17 AC 532 ms
108,344 KB
testcase_18 AC 54 ms
66,416 KB
testcase_19 AC 110 ms
79,592 KB
testcase_20 AC 53 ms
66,428 KB
testcase_21 AC 162 ms
83,768 KB
testcase_22 AC 79 ms
74,632 KB
testcase_23 AC 186 ms
85,156 KB
testcase_24 AC 138 ms
81,944 KB
testcase_25 AC 262 ms
91,300 KB
testcase_26 TLE -
testcase_27 AC 140 ms
82,084 KB
testcase_28 TLE -
testcase_29 MLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 AC 215 ms
86,948 KB
testcase_34 AC 155 ms
83,736 KB
testcase_35 AC 1,107 ms
147,492 KB
testcase_36 AC 37 ms
53,460 KB
testcase_37 AC 279 ms
91,960 KB
testcase_38 AC 68 ms
69,492 KB
testcase_39 TLE -
testcase_40 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


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

PC = [0] * (1 << n)
for i in range(1, 1 << n):
    p = i & -i
    PC[i] = PC[i ^ p] + 1

nCk = [[0] * (n + 1) for _ in range(n + 1)]
nCk[0][0] = 1
for i in range(1, n + 1):
    nCk[i][0] = 1
    for j in range(1, i + 1):
        nCk[i][j] = nCk[i - 1][j - 1] + nCk[i - 1][j]


dp = [0] * (1 << n)
for _ in range(m):
    S = int(input(), 2)
    dp[S] += 1

C = [0] * (n + 1)
C[k] = 1
for i in range(k + 1, n + 1):
    C[i] = 1
    for j in range(i):
        C[i] -= C[j] * nCk[i][j]


for i in range(n):
    dbit = 1 << i
    for s in range(0, 1 << n, 2 * dbit):
        for j in range(dbit):
            dp[s + j] += dp[s + dbit + j]

for bit in range(1 << n):
    dp[bit] *= C[PC[bit]]

for i in range(n):
    dbit = 1 << i
    for s in range(0, 1 << n, 2 * dbit):
        for j in range(dbit):
            dp[s + dbit + j] += dp[s + j]


ans = [1 << 30] * m
for bit in range(1 << n):
    c = dp[bit] - 1
    if c >= 0:
        ans[c] = min(ans[c], PC[bit])

for i in range(m - 2, -1, -1):
    ans[i] = min(ans[i], ans[i + 1])

print(*ans, sep="\n")
0