結果

問題 No.2669 Generalized Hitting Set
ユーザー 👑 rin204rin204
提出日時 2024-04-01 23:38:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,739 ms / 4,000 ms
コード長 1,153 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 216,928 KB
最終ジャッジ日時 2024-04-01 23:39:16
合計ジャッジ時間 40,305 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
59,588 KB
testcase_01 AC 41 ms
59,588 KB
testcase_02 AC 52 ms
64,324 KB
testcase_03 AC 165 ms
82,152 KB
testcase_04 AC 150 ms
81,000 KB
testcase_05 AC 139 ms
80,104 KB
testcase_06 AC 195 ms
83,304 KB
testcase_07 AC 89 ms
76,904 KB
testcase_08 AC 98 ms
77,544 KB
testcase_09 AC 149 ms
80,744 KB
testcase_10 AC 115 ms
78,440 KB
testcase_11 AC 100 ms
77,416 KB
testcase_12 AC 184 ms
81,768 KB
testcase_13 AC 3,315 ms
206,776 KB
testcase_14 AC 424 ms
92,088 KB
testcase_15 AC 62 ms
68,504 KB
testcase_16 AC 148 ms
79,928 KB
testcase_17 AC 422 ms
92,088 KB
testcase_18 AC 58 ms
66,428 KB
testcase_19 AC 99 ms
74,620 KB
testcase_20 AC 58 ms
66,428 KB
testcase_21 AC 151 ms
79,800 KB
testcase_22 AC 83 ms
71,580 KB
testcase_23 AC 267 ms
85,100 KB
testcase_24 AC 198 ms
82,024 KB
testcase_25 AC 310 ms
87,404 KB
testcase_26 AC 3,249 ms
208,876 KB
testcase_27 AC 184 ms
81,772 KB
testcase_28 AC 3,591 ms
216,688 KB
testcase_29 AC 3,596 ms
216,700 KB
testcase_30 AC 3,454 ms
216,704 KB
testcase_31 AC 3,488 ms
216,704 KB
testcase_32 AC 3,389 ms
216,700 KB
testcase_33 AC 270 ms
85,228 KB
testcase_34 AC 231 ms
84,456 KB
testcase_35 AC 973 ms
115,052 KB
testcase_36 AC 40 ms
59,588 KB
testcase_37 AC 237 ms
83,896 KB
testcase_38 AC 67 ms
69,000 KB
testcase_39 AC 3,739 ms
216,924 KB
testcase_40 AC 3,713 ms
216,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


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


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 bit in range(1 << n):
    p = PC[bit >> 12] + PC[bit & 4095]
    dp[bit] *= C[p]

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


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