結果
問題 | No.2669 Generalized Hitting Set |
ユーザー | suisen |
提出日時 | 2023-09-21 02:22:41 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,704 bytes |
コンパイル時間 | 235 ms |
コンパイル使用メモリ | 81,572 KB |
実行使用メモリ | 219,792 KB |
最終ジャッジ日時 | 2024-01-16 20:53:39 |
合計ジャッジ時間 | 32,681 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 73 ms
76,784 KB |
testcase_01 | AC | 71 ms
76,784 KB |
testcase_02 | AC | 81 ms
81,256 KB |
testcase_03 | AC | 202 ms
95,384 KB |
testcase_04 | AC | 182 ms
93,448 KB |
testcase_05 | AC | 167 ms
92,220 KB |
testcase_06 | AC | 215 ms
97,132 KB |
testcase_07 | AC | 116 ms
87,628 KB |
testcase_08 | AC | 124 ms
88,384 KB |
testcase_09 | AC | 177 ms
93,128 KB |
testcase_10 | AC | 146 ms
89,516 KB |
testcase_11 | AC | 127 ms
87,756 KB |
testcase_12 | AC | 216 ms
94,540 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 102 ms
86,236 KB |
testcase_16 | AC | 219 ms
90,200 KB |
testcase_17 | RE | - |
testcase_18 | AC | 94 ms
85,996 KB |
testcase_19 | AC | 150 ms
88,152 KB |
testcase_20 | AC | 86 ms
82,288 KB |
testcase_21 | AC | 211 ms
90,072 KB |
testcase_22 | AC | 122 ms
87,000 KB |
testcase_23 | AC | 319 ms
99,168 KB |
testcase_24 | AC | 219 ms
95,240 KB |
testcase_25 | AC | 388 ms
101,444 KB |
testcase_26 | RE | - |
testcase_27 | AC | 216 ms
93,368 KB |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | AC | 316 ms
98,836 KB |
testcase_34 | AC | 276 ms
98,028 KB |
testcase_35 | RE | - |
testcase_36 | AC | 71 ms
76,784 KB |
testcase_37 | AC | 340 ms
94,168 KB |
testcase_38 | AC | 105 ms
86,616 KB |
testcase_39 | RE | - |
testcase_40 | RE | - |
ソースコード
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 = 20 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')