結果

問題 No.2669 Generalized Hitting Set
ユーザー kotatsugamekotatsugame
提出日時 2024-03-08 22:35:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,308 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 70,892 KB
実行使用メモリ 207,352 KB
最終ジャッジ日時 2024-03-08 22:36:03
合計ジャッジ時間 8,122 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
136,640 KB
testcase_01 AC 34 ms
136,640 KB
testcase_02 AC 34 ms
136,640 KB
testcase_03 AC 54 ms
137,280 KB
testcase_04 AC 51 ms
137,280 KB
testcase_05 AC 49 ms
137,152 KB
testcase_06 AC 66 ms
137,280 KB
testcase_07 AC 38 ms
136,768 KB
testcase_08 AC 42 ms
136,768 KB
testcase_09 AC 52 ms
137,152 KB
testcase_10 AC 47 ms
136,896 KB
testcase_11 AC 39 ms
136,768 KB
testcase_12 AC 56 ms
137,280 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 #

#include<iostream>
#include<cassert>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::static_modint<999000061>;
int N,M,K;
int cnt[1<<24];
mint now[1<<24];
mint ALL[1<<24];
mint comb[25][25],coef[25][25];
int ans[3<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M>>K;
	for(int i=0;i<M;i++)
	{
		string s;cin>>s;
		int S=0;
		for(int j=0;j<N;j++)if(s[j]=='1')S|=1<<j;
		cnt[S]++;
	}
	for(int k=0;k<N;k++)for(int i=0;i<1<<N;i++)if(i>>k&1)cnt[i^1<<k]+=cnt[i];
	for(int i=0;i<=N;i++)
	{
		comb[i][0]=comb[i][i]=1;
		for(int j=1;j<i;j++)comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
	}
	for(int k=K;k<=N;k++)coef[k][k]=1;
	for(int k=N-1;k>=K;k--)
	{
		for(int i=k+1;i<=N;i++)
		{
			for(int j=1;j<=N;j++)coef[k][j]-=coef[i][j]*comb[i][k];
		}
	}
	for(int k=K;k<=N;k++)
	{
		for(int i=0;i<1<<N;i++)now[i]=__builtin_popcount(i)==k?mint::raw(cnt[i]):0;
		for(int k=0;k<N;k++)for(int i=0;i<1<<N;i++)if(i>>k&1)now[i]+=now[i^1<<k];
		mint c=0;
		for(int i=k;i>=K;i--)c+=coef[i][k];
		for(int i=0;i<1<<N;i++)ALL[i]+=c*now[i];
	}
	for(int i=0;i<=M;i++)ans[i]=1e9;
	for(int i=0;i<1<<N;i++)
	{
		int t=ALL[i].val();
		assert(0<=t&&t<=M);
		ans[t]=min(ans[t],__builtin_popcount(i));
	}
	for(int i=M;i>=1;i--)ans[i-1]=min(ans[i-1],ans[i]);
	for(int i=1;i<=M;i++)cout<<ans[i]<<"\n";
}
0