結果

問題 No.2669 Generalized Hitting Set
ユーザー suisensuisen
提出日時 2024-01-14 04:33:35
言語 Nim
(2.0.2)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,298 bytes
コンパイル時間 4,562 ms
コンパイル使用メモリ 65,492 KB
実行使用メモリ 268,360 KB
最終ジャッジ日時 2024-01-16 20:59:54
合計ジャッジ時間 34,358 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
134,060 KB
testcase_01 AC 53 ms
134,060 KB
testcase_02 AC 53 ms
134,060 KB
testcase_03 AC 364 ms
135,596 KB
testcase_04 AC 311 ms
135,340 KB
testcase_05 AC 261 ms
135,084 KB
testcase_06 AC 422 ms
135,852 KB
testcase_07 AC 102 ms
134,316 KB
testcase_08 AC 128 ms
134,444 KB
testcase_09 AC 289 ms
135,212 KB
testcase_10 AC 174 ms
134,700 KB
testcase_11 AC 105 ms
134,316 KB
testcase_12 AC 340 ms
135,468 KB
testcase_13 MLE -
testcase_14 AC 252 ms
150,472 KB
testcase_15 AC 54 ms
134,188 KB
testcase_16 AC 97 ms
138,184 KB
testcase_17 AC 251 ms
150,472 KB
testcase_18 AC 53 ms
134,060 KB
testcase_19 AC 75 ms
136,108 KB
testcase_20 AC 54 ms
134,060 KB
testcase_21 AC 100 ms
138,184 KB
testcase_22 AC 66 ms
135,084 KB
testcase_23 AC 483 ms
136,620 KB
testcase_24 AC 358 ms
135,596 KB
testcase_25 AC 475 ms
139,976 KB
testcase_26 MLE -
testcase_27 AC 278 ms
136,108 KB
testcase_28 MLE -
testcase_29 MLE -
testcase_30 MLE -
testcase_31 MLE -
testcase_32 MLE -
testcase_33 AC 438 ms
137,900 KB
testcase_34 AC 455 ms
136,108 KB
testcase_35 AC 793 ms
168,392 KB
testcase_36 AC 53 ms
134,060 KB
testcase_37 AC 153 ms
142,280 KB
testcase_38 AC 58 ms
134,572 KB
testcase_39 MLE -
testcase_40 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils
import strutils
import algorithm

const N_MAX = 24

var binom: array[N_MAX + 1, array[N_MAX + 1, int]]
for i in 0 .. N_MAX:
    binom[i][0] = 1
    for j in 1 .. i:
        binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j]

var popcnt: array[1 shl N_MAX, int]
for t in 1 ..< 1 shl N_MAX:
    popcnt[t] = 1 + popcnt[t and (t - 1)]

var n, m, k: int
var nmk = stdin.readLine.split.map parseInt
n = nmk[0]
m = nmk[1]
k = nmk[2]

var f = newSeq[int](1 shl n)

for i in 0 ..< m:
    # reversed, but it's ok
    let s = stdin.readLine
    var x = 0
    for j in 0 ..< n:
        x += int(s[j] == '1') shl j
    f[x] += 1

var a = newSeq[int](n + 1)
for l in k .. n:
    a[l] = binom[l - 1][l - k]
    if bool((l - k) and 1):
        a[l] = -a[l]

# supset zeta
proc supset_zeta(): void =
    var b = 1
    while b < 1 shl n:
        for l in countup(0, (1 shl n) - 1, 2 * b):
            for p in l ..< l + b:
                f[p] += f[p + b]
        b *= 2
supset_zeta()

for t in 0 ..< 1 shl n:
    f[t] *= a[popcnt[t]]

# subset zeta

f.reverse
supset_zeta()
f.reverse

var g = newSeq[int](m + 1)
for i in 0 .. m:
    g[i] = n
for t in 0 ..< 1 shl n:
    g[f[t]] = min(g[f[t]], popcnt[t])

for p in countdown(m - 1, 0):
    g[p] = min(g[p], g[p + 1])

for p in 1 .. m:
    echo g[p]
0