結果

問題 No.2669 Generalized Hitting Set
ユーザー 👑 rin204rin204
提出日時 2024-04-02 20:47:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,908 ms / 4,000 ms
コード長 1,190 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 216,704 KB
最終ジャッジ日時 2024-04-02 20:47:46
合計ジャッジ時間 32,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
59,580 KB
testcase_01 AC 39 ms
59,580 KB
testcase_02 AC 75 ms
64,324 KB
testcase_03 AC 101 ms
81,944 KB
testcase_04 AC 95 ms
80,664 KB
testcase_05 AC 100 ms
79,892 KB
testcase_06 AC 120 ms
82,836 KB
testcase_07 AC 66 ms
76,820 KB
testcase_08 AC 71 ms
77,204 KB
testcase_09 AC 100 ms
80,280 KB
testcase_10 AC 86 ms
78,100 KB
testcase_11 AC 76 ms
76,948 KB
testcase_12 AC 122 ms
81,432 KB
testcase_13 AC 2,496 ms
206,772 KB
testcase_14 AC 332 ms
92,084 KB
testcase_15 AC 60 ms
68,504 KB
testcase_16 AC 131 ms
79,796 KB
testcase_17 AC 338 ms
92,084 KB
testcase_18 AC 65 ms
68,516 KB
testcase_19 AC 94 ms
77,704 KB
testcase_20 AC 55 ms
66,440 KB
testcase_21 AC 127 ms
79,796 KB
testcase_22 AC 74 ms
73,884 KB
testcase_23 AC 189 ms
84,760 KB
testcase_24 AC 141 ms
81,940 KB
testcase_25 AC 231 ms
87,064 KB
testcase_26 AC 2,558 ms
208,604 KB
testcase_27 AC 149 ms
81,176 KB
testcase_28 AC 2,876 ms
216,464 KB
testcase_29 AC 2,908 ms
216,604 KB
testcase_30 AC 2,793 ms
216,492 KB
testcase_31 AC 2,814 ms
216,612 KB
testcase_32 AC 2,716 ms
216,488 KB
testcase_33 AC 196 ms
85,016 KB
testcase_34 AC 169 ms
84,500 KB
testcase_35 AC 750 ms
114,840 KB
testcase_36 AC 41 ms
59,580 KB
testcase_37 AC 201 ms
83,892 KB
testcase_38 AC 69 ms
71,068 KB
testcase_39 AC 2,540 ms
216,560 KB
testcase_40 AC 2,559 ms
216,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline

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

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

dp = [0] * (1 << n)
for _ in range(m):
    S = int(input(), 2)
    dp[S] += 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]

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 t in range(2):
    pm = 1
    if t == 1:
        pm = -1
    for i in range(n):
        dbit = 1 << i
        for s in range(0, 1 << n, 2 * dbit):
            for j in range(s + dbit * t, s + dbit * (t + 1)):
                dp[j] += dp[pm * dbit + j]

    if t == 1:
        break
    for bit in range(1 << n):
        p = PC[bit >> 12] + PC[bit & 4095]
        dp[bit] *= C[p]


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

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

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