結果

問題 No.2669 Generalized Hitting Set
ユーザー chineristACchineristAC
提出日時 2024-01-14 01:55:26
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,346 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 214,344 KB
最終ジャッジ日時 2024-01-16 20:54:47
合計ジャッジ時間 8,161 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
66,492 KB
testcase_01 AC 52 ms
66,492 KB
testcase_02 AC 60 ms
68,952 KB
testcase_03 AC 115 ms
84,684 KB
testcase_04 AC 114 ms
83,160 KB
testcase_05 AC 117 ms
82,124 KB
testcase_06 AC 150 ms
86,248 KB
testcase_07 AC 85 ms
78,440 KB
testcase_08 AC 91 ms
78,796 KB
testcase_09 AC 131 ms
82,636 KB
testcase_10 AC 113 ms
80,104 KB
testcase_11 AC 94 ms
78,284 KB
testcase_12 AC 161 ms
84,068 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
from heapq import heappop,heappush
from collections import deque
import random
import bisect

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

n,m,k = mi()
cnt = [0] * (1<<n)
for _ in range(m):
    S = input()
    val = 0
    for s in S:
        val = (val<<1) ^ (int(s))
    cnt[val] += 1

COMB = [[0]*(n+1) for i in range(n+1)]
COMB[0][0] = 1
for i in range(1,n+1):
    COMB[i][0] = 1
    for j in range(1,i+1):
        COMB[i][j] = COMB[i-1][j] + COMB[i-1][j-1]
fact = [1] * (n+1)
for i in range(2,n+1):
    fact[i] = i * fact[i-1]


f = [0] * (n+1)
f[k] = 1
for i in range(k+1,n+1):
    f[i] = 1
    for j in range(k,i):
        f[i] -= COMB[i][j] * f[j] 

#print(f)

for i in range(n):
    t = 1<<i
    for S in range(1<<n):
        if S & t:
            cnt[S^t] += cnt[S]

#print(cnt)

popcnt = [bin(i).count("1") for i in range(1<<12)]
mask = 2**12-1
for S in range(1<<n):
    p = popcnt[S & mask] + popcnt[S>>12]
    cnt[S] *= f[p]


for i in range(n):
    t = 1<<i
    for S in range(1<<n):
        if S & t:
            cnt[S] += cnt[S^t]


g = [n+1] * (m+1)
for S in range(1<<n):
    g[cnt[S]] = min(g[cnt[S]],popcnt[S & mask] + popcnt[S>>12])

for i in range(m)[::-1]:
    g[i] = min(g[i],g[i+1])

print(*g[1:],sep="\n")
    

0