結果
問題 | No.2669 Generalized Hitting Set |
ユーザー | 👑 rin204 |
提出日時 | 2024-04-01 23:40:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 3,518 ms / 4,000 ms |
コード長 | 1,193 bytes |
コンパイル時間 | 458 ms |
コンパイル使用メモリ | 82,604 KB |
実行使用メモリ | 217,344 KB |
最終ジャッジ日時 | 2024-09-30 22:52:27 |
合計ジャッジ時間 | 39,528 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
58,496 KB |
testcase_01 | AC | 45 ms
57,984 KB |
testcase_02 | AC | 61 ms
64,256 KB |
testcase_03 | AC | 116 ms
82,176 KB |
testcase_04 | AC | 110 ms
81,280 KB |
testcase_05 | AC | 109 ms
80,060 KB |
testcase_06 | AC | 139 ms
83,772 KB |
testcase_07 | AC | 74 ms
77,056 KB |
testcase_08 | AC | 77 ms
77,560 KB |
testcase_09 | AC | 111 ms
80,512 KB |
testcase_10 | AC | 92 ms
78,336 KB |
testcase_11 | AC | 84 ms
77,440 KB |
testcase_12 | AC | 136 ms
82,176 KB |
testcase_13 | AC | 3,346 ms
207,104 KB |
testcase_14 | AC | 442 ms
92,416 KB |
testcase_15 | AC | 66 ms
67,584 KB |
testcase_16 | AC | 159 ms
80,128 KB |
testcase_17 | AC | 435 ms
92,552 KB |
testcase_18 | AC | 65 ms
67,200 KB |
testcase_19 | AC | 108 ms
75,040 KB |
testcase_20 | AC | 61 ms
65,536 KB |
testcase_21 | AC | 152 ms
80,384 KB |
testcase_22 | AC | 84 ms
70,784 KB |
testcase_23 | AC | 210 ms
85,324 KB |
testcase_24 | AC | 151 ms
82,560 KB |
testcase_25 | AC | 264 ms
87,424 KB |
testcase_26 | AC | 3,236 ms
209,232 KB |
testcase_27 | AC | 153 ms
81,920 KB |
testcase_28 | AC | 3,480 ms
217,216 KB |
testcase_29 | AC | 3,518 ms
217,264 KB |
testcase_30 | AC | 3,395 ms
217,216 KB |
testcase_31 | AC | 3,411 ms
216,960 KB |
testcase_32 | AC | 3,306 ms
216,932 KB |
testcase_33 | AC | 216 ms
85,156 KB |
testcase_34 | AC | 167 ms
84,668 KB |
testcase_35 | AC | 919 ms
115,200 KB |
testcase_36 | AC | 45 ms
57,984 KB |
testcase_37 | AC | 251 ms
84,548 KB |
testcase_38 | AC | 76 ms
68,096 KB |
testcase_39 | AC | 3,387 ms
217,216 KB |
testcase_40 | AC | 3,414 ms
217,344 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 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")