結果

問題 No.2669 Generalized Hitting Set
ユーザー 沙耶花沙耶花
提出日時 2024-03-08 23:57:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,535 ms / 4,000 ms
コード長 1,315 bytes
コンパイル時間 4,635 ms
コンパイル使用メモリ 263,884 KB
実行使用メモリ 70,124 KB
最終ジャッジ日時 2024-03-08 23:58:16
合計ジャッジ時間 25,010 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 251 ms
6,548 KB
testcase_04 AC 206 ms
6,676 KB
testcase_05 AC 170 ms
6,676 KB
testcase_06 AC 309 ms
6,676 KB
testcase_07 AC 44 ms
6,676 KB
testcase_08 AC 67 ms
6,676 KB
testcase_09 AC 191 ms
6,676 KB
testcase_10 AC 104 ms
6,676 KB
testcase_11 AC 46 ms
6,676 KB
testcase_12 AC 234 ms
6,676 KB
testcase_13 AC 1,062 ms
68,976 KB
testcase_14 AC 118 ms
12,256 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 27 ms
6,676 KB
testcase_17 AC 115 ms
12,260 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 15 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 28 ms
6,676 KB
testcase_22 AC 8 ms
6,676 KB
testcase_23 AC 380 ms
6,676 KB
testcase_24 AC 257 ms
6,676 KB
testcase_25 AC 348 ms
6,884 KB
testcase_26 AC 1,131 ms
69,104 KB
testcase_27 AC 182 ms
6,676 KB
testcase_28 AC 1,530 ms
70,124 KB
testcase_29 AC 1,531 ms
70,124 KB
testcase_30 AC 1,521 ms
70,040 KB
testcase_31 AC 1,535 ms
70,024 KB
testcase_32 AC 1,525 ms
70,036 KB
testcase_33 AC 332 ms
6,900 KB
testcase_34 AC 331 ms
6,676 KB
testcase_35 AC 531 ms
21,092 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 AC 55 ms
8,164 KB
testcase_38 AC 5 ms
6,676 KB
testcase_39 AC 1,528 ms
70,016 KB
testcase_40 AC 1,535 ms
70,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001
long long comb[25][25];
int dp[1<<24];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	comb[0][0] = 1;
	for(int i=1;i<=24;i++){
		for(int j=0;j<=i;j++){
			if(j!=0)comb[i][j] += comb[i-1][j-1];
			comb[i][j] += comb[i-1][j];
		}
	}
	
	int n,m,k;
	cin>>n>>m>>k;
	vector<long long> kei(n+1);
	kei[k] = 1;
	for(int i=k+1;i<=n;i++){
		for(int j=k;j<i;j++){
			kei[i] += comb[i][j] * kei[j];
		}
		kei[i] = 1-kei[i];
	}
	
	rep(i,m){
		string s;
		cin>>s;
		int ii = 0;
		rep(j,n){
			if(s[j]=='1')ii |= 1<<j;
		}
		dp[ii]++;
	}
	rep(i,n){
		rep(j,1<<n){
			if((j>>i)&1){
				
			}
			else{
				dp[j] += dp[j^(1<<i)];
			}
			
		}
	}
	rep(i,1<<n)dp[i] *= kei[__builtin_popcount(i)];

	rep(i,n){
		rep(j,1<<n){
			if((j>>i)&1){
				
			}
			else{
				dp[j^(1<<i)] += dp[j];
			}
			
		}
	}
	
	
	vector<int> ans(m+1,Inf32);
	rep(i,1<<n){
		//if(dp[i]<0)cout<<i<<' '<<dp[i]<<endl;
		int t = __builtin_popcount(i);
		ans[dp[i]] = min(ans[dp[i]],t);
	}
	for(int i=m;i>=1;i--)ans[i-1] = min(ans[i-1],ans[i]);
	rep(i,m){
		cout<<ans[i+1]<<endl;
	}
	
	
	return 0;
}
0