結果

問題 No.2669 Generalized Hitting Set
ユーザー 👑 rin204rin204
提出日時 2024-04-01 22:59:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,150 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 199,608 KB
最終ジャッジ日時 2024-04-01 23:00:08
合計ジャッジ時間 8,851 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 48 ms
61,712 KB
testcase_03 AC 165 ms
82,016 KB
testcase_04 AC 148 ms
80,864 KB
testcase_05 AC 138 ms
79,968 KB
testcase_06 AC 188 ms
83,296 KB
testcase_07 AC 87 ms
76,896 KB
testcase_08 AC 96 ms
77,536 KB
testcase_09 AC 148 ms
80,608 KB
testcase_10 AC 117 ms
78,432 KB
testcase_11 AC 98 ms
77,152 KB
testcase_12 AC 173 ms
81,632 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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())

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):
    for bit in range(1 << n):
        if bit >> i & 1:
            dp[bit ^ (1 << i)] += dp[bit]

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

for i in range(n):
    for bit in range(1 << n):
        if bit >> i & 1:
            dp[bit] += dp[bit ^ (1 << i)]

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

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

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