結果
問題 | No.2669 Generalized Hitting Set |
ユーザー | 👑 rin204 |
提出日時 | 2024-04-02 20:26:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,536 ms / 4,000 ms |
コード長 | 1,304 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 82,352 KB |
実行使用メモリ | 217,204 KB |
最終ジャッジ日時 | 2024-09-30 23:18:44 |
合計ジャッジ時間 | 28,818 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
53,872 KB |
testcase_01 | AC | 36 ms
52,656 KB |
testcase_02 | AC | 48 ms
64,092 KB |
testcase_03 | AC | 93 ms
82,324 KB |
testcase_04 | AC | 91 ms
81,116 KB |
testcase_05 | AC | 89 ms
79,648 KB |
testcase_06 | AC | 111 ms
83,628 KB |
testcase_07 | AC | 63 ms
77,472 KB |
testcase_08 | AC | 68 ms
77,944 KB |
testcase_09 | AC | 96 ms
80,520 KB |
testcase_10 | AC | 81 ms
78,456 KB |
testcase_11 | AC | 76 ms
77,556 KB |
testcase_12 | AC | 112 ms
82,100 KB |
testcase_13 | AC | 2,133 ms
207,268 KB |
testcase_14 | AC | 336 ms
92,840 KB |
testcase_15 | AC | 66 ms
69,260 KB |
testcase_16 | AC | 121 ms
80,388 KB |
testcase_17 | AC | 336 ms
92,560 KB |
testcase_18 | AC | 59 ms
67,668 KB |
testcase_19 | AC | 87 ms
77,972 KB |
testcase_20 | AC | 59 ms
66,772 KB |
testcase_21 | AC | 120 ms
80,236 KB |
testcase_22 | AC | 69 ms
74,760 KB |
testcase_23 | AC | 173 ms
85,160 KB |
testcase_24 | AC | 136 ms
83,200 KB |
testcase_25 | AC | 207 ms
87,684 KB |
testcase_26 | AC | 2,220 ms
209,060 KB |
testcase_27 | AC | 132 ms
81,372 KB |
testcase_28 | AC | 2,536 ms
216,880 KB |
testcase_29 | AC | 2,479 ms
216,996 KB |
testcase_30 | AC | 2,468 ms
217,080 KB |
testcase_31 | AC | 2,473 ms
216,988 KB |
testcase_32 | AC | 2,386 ms
217,204 KB |
testcase_33 | AC | 177 ms
85,716 KB |
testcase_34 | AC | 151 ms
84,824 KB |
testcase_35 | AC | 741 ms
115,272 KB |
testcase_36 | AC | 37 ms
53,428 KB |
testcase_37 | AC | 172 ms
84,540 KB |
testcase_38 | AC | 64 ms
71,376 KB |
testcase_39 | AC | 2,223 ms
216,776 KB |
testcase_40 | AC | 2,189 ms
217,200 KB |
ソースコード
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")