結果
問題 | No.2669 Generalized Hitting Set |
ユーザー | suisen |
提出日時 | 2023-12-31 03:32:33 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,704 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 81,572 KB |
実行使用メモリ | 351,292 KB |
最終ジャッジ日時 | 2024-01-16 20:54:14 |
合計ジャッジ時間 | 24,539 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 161 ms
199,664 KB |
testcase_01 | AC | 161 ms
199,664 KB |
testcase_02 | AC | 169 ms
204,136 KB |
testcase_03 | AC | 284 ms
218,264 KB |
testcase_04 | AC | 266 ms
216,324 KB |
testcase_05 | AC | 253 ms
215,100 KB |
testcase_06 | AC | 306 ms
220,012 KB |
testcase_07 | AC | 211 ms
210,508 KB |
testcase_08 | AC | 221 ms
211,264 KB |
testcase_09 | AC | 262 ms
216,004 KB |
testcase_10 | AC | 235 ms
212,400 KB |
testcase_11 | AC | 213 ms
210,636 KB |
testcase_12 | AC | 302 ms
217,420 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 701 ms
225,240 KB |
testcase_15 | AC | 187 ms
208,988 KB |
testcase_16 | AC | 303 ms
212,952 KB |
testcase_17 | AC | 691 ms
225,240 KB |
testcase_18 | AC | 183 ms
208,748 KB |
testcase_19 | AC | 239 ms
210,904 KB |
testcase_20 | AC | 175 ms
205,040 KB |
testcase_21 | AC | 301 ms
212,824 KB |
testcase_22 | AC | 207 ms
209,752 KB |
testcase_23 | AC | 408 ms
222,048 KB |
testcase_24 | AC | 305 ms
218,120 KB |
testcase_25 | AC | 458 ms
224,324 KB |
testcase_26 | TLE | - |
testcase_27 | AC | 303 ms
216,248 KB |
testcase_28 | MLE | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
ソースコード
from typing import List def supset_zeta(f: List[int]): n = len(f) b = 1 while b < n: l = 0 while l < n: for p in range(l, l + b): f[p] += f[p + b] l += 2 * b b *= 2 def subset_zeta(f: List[int]): n = len(f) b = 1 while b < n: l = 0 while l < n: for p in range(l, l + b): f[p + b] += f[p] l += 2 * b b *= 2 N_MAX = 24 popcnt = [0] * (1 << N_MAX) for t in range(1, 1 << N_MAX): popcnt[t] = 1 + popcnt[t & (t - 1)] def calc_f(n: int, m: int, k: int, s: List[int]): binom = [[0] * (n + 1) for _ in range(n + 1)] for i in range(n + 1): binom[i][0] = 1 for j in range(1, i + 1): binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j] a = [0] * (n + 1) for l in range(k, n + 1): a[l] = 1 for i in range(k, l): a[l] -= a[i] * binom[l][i] f = [0] * (1 << n) for u in s: f[u] += 1 supset_zeta(f) for t in range(1 << n): if popcnt[t] < k: f[t] = 0 else: f[t] *= a[popcnt[t]] subset_zeta(f) return f def calc_g(n: int, m: int, f: List[int]): g = [n + 1] * (m + 1) for t in range(1 << n): g[f[t]] = min(g[f[t]], popcnt[t]) for p in reversed(range(m)): g[p] = min(g[p], g[p + 1]) return g if __name__ == '__main__': n, m, k = map(int, input().split()) s = [0] * m for i in range(m): si = input() for j in range(n): s[i] |= (ord(si[j]) - ord('0')) << j f = calc_f(n, m, k, s) g = calc_g(n, m, f) print(*g[1:], sep='\n')