結果
問題 | No.2669 Generalized Hitting Set |
ユーザー | 👑 rin204 |
提出日時 | 2024-04-02 20:47:12 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,644 ms / 4,000 ms |
コード長 | 1,190 bytes |
コンパイル時間 | 265 ms |
コンパイル使用メモリ | 82,472 KB |
実行使用メモリ | 217,260 KB |
最終ジャッジ日時 | 2024-09-30 23:19:35 |
合計ジャッジ時間 | 29,162 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
59,040 KB |
testcase_01 | AC | 39 ms
59,356 KB |
testcase_02 | AC | 52 ms
64,548 KB |
testcase_03 | AC | 101 ms
82,520 KB |
testcase_04 | AC | 97 ms
81,072 KB |
testcase_05 | AC | 93 ms
80,524 KB |
testcase_06 | AC | 119 ms
83,616 KB |
testcase_07 | AC | 66 ms
77,376 KB |
testcase_08 | AC | 73 ms
77,984 KB |
testcase_09 | AC | 102 ms
80,880 KB |
testcase_10 | AC | 86 ms
78,856 KB |
testcase_11 | AC | 75 ms
77,636 KB |
testcase_12 | AC | 118 ms
82,060 KB |
testcase_13 | AC | 2,261 ms
207,204 KB |
testcase_14 | AC | 296 ms
92,612 KB |
testcase_15 | AC | 61 ms
69,348 KB |
testcase_16 | AC | 122 ms
80,400 KB |
testcase_17 | AC | 297 ms
92,556 KB |
testcase_18 | AC | 62 ms
68,296 KB |
testcase_19 | AC | 94 ms
78,360 KB |
testcase_20 | AC | 54 ms
68,436 KB |
testcase_21 | AC | 120 ms
80,392 KB |
testcase_22 | AC | 72 ms
75,472 KB |
testcase_23 | AC | 172 ms
85,504 KB |
testcase_24 | AC | 134 ms
82,468 KB |
testcase_25 | AC | 210 ms
87,404 KB |
testcase_26 | AC | 2,548 ms
209,632 KB |
testcase_27 | AC | 130 ms
81,748 KB |
testcase_28 | AC | 2,625 ms
216,912 KB |
testcase_29 | AC | 2,644 ms
216,888 KB |
testcase_30 | AC | 2,560 ms
216,992 KB |
testcase_31 | AC | 2,555 ms
217,260 KB |
testcase_32 | AC | 2,457 ms
216,904 KB |
testcase_33 | AC | 180 ms
85,740 KB |
testcase_34 | AC | 145 ms
85,168 KB |
testcase_35 | AC | 656 ms
115,348 KB |
testcase_36 | AC | 40 ms
58,812 KB |
testcase_37 | AC | 176 ms
84,596 KB |
testcase_38 | AC | 65 ms
72,840 KB |
testcase_39 | AC | 2,309 ms
217,104 KB |
testcase_40 | AC | 2,317 ms
217,052 KB |
ソースコード
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")