結果

問題 No.2669 Generalized Hitting Set
ユーザー 👑 rin204rin204
提出日時 2024-04-02 20:26:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,825 ms / 4,000 ms
コード長 1,304 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 216,760 KB
最終ジャッジ日時 2024-04-02 20:27:11
合計ジャッジ時間 31,555 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 50 ms
64,184 KB
testcase_03 AC 111 ms
81,792 KB
testcase_04 AC 96 ms
80,768 KB
testcase_05 AC 92 ms
79,744 KB
testcase_06 AC 122 ms
83,072 KB
testcase_07 AC 66 ms
76,668 KB
testcase_08 AC 70 ms
77,184 KB
testcase_09 AC 99 ms
80,256 KB
testcase_10 AC 83 ms
78,080 KB
testcase_11 AC 77 ms
77,056 KB
testcase_12 AC 122 ms
81,408 KB
testcase_13 AC 2,822 ms
206,856 KB
testcase_14 AC 322 ms
92,200 KB
testcase_15 AC 65 ms
68,620 KB
testcase_16 AC 131 ms
80,040 KB
testcase_17 AC 323 ms
92,200 KB
testcase_18 AC 59 ms
68,492 KB
testcase_19 AC 100 ms
77,684 KB
testcase_20 AC 57 ms
66,404 KB
testcase_21 AC 126 ms
80,040 KB
testcase_22 AC 73 ms
73,720 KB
testcase_23 AC 190 ms
84,744 KB
testcase_24 AC 144 ms
82,560 KB
testcase_25 AC 232 ms
87,304 KB
testcase_26 AC 2,465 ms
208,648 KB
testcase_27 AC 139 ms
81,032 KB
testcase_28 AC 2,825 ms
216,512 KB
testcase_29 AC 2,771 ms
216,652 KB
testcase_30 AC 2,760 ms
216,652 KB
testcase_31 AC 2,759 ms
216,652 KB
testcase_32 AC 2,669 ms
216,512 KB
testcase_33 AC 197 ms
85,128 KB
testcase_34 AC 167 ms
84,352 KB
testcase_35 AC 723 ms
114,824 KB
testcase_36 AC 37 ms
53,460 KB
testcase_37 AC 192 ms
84,008 KB
testcase_38 AC 69 ms
71,172 KB
testcase_39 AC 2,418 ms
216,612 KB
testcase_40 AC 2,337 ms
216,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline


def popcount32(x):
    x = x - ((x >> 1) & 0x55555555)
    x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
    x = (x + (x >> 4)) & 0x0F0F0F0F
    x += x >> 8
    x += x >> 16
    return x & 0x0000003F


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


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


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

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


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

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

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