結果

問題 No.2669 Generalized Hitting Set
ユーザー 👑 kmjpkmjp
提出日時 2024-03-10 11:03:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,806 ms / 4,000 ms
コード長 1,596 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 204,340 KB
実行使用メモリ 135,796 KB
最終ジャッジ日時 2024-03-10 11:04:03
合計ジャッジ時間 27,611 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 277 ms
6,548 KB
testcase_04 AC 204 ms
6,548 KB
testcase_05 AC 167 ms
6,548 KB
testcase_06 AC 310 ms
6,548 KB
testcase_07 AC 45 ms
6,548 KB
testcase_08 AC 65 ms
6,548 KB
testcase_09 AC 215 ms
6,548 KB
testcase_10 AC 102 ms
6,548 KB
testcase_11 AC 47 ms
6,548 KB
testcase_12 AC 234 ms
6,548 KB
testcase_13 AC 1,369 ms
135,012 KB
testcase_14 AC 134 ms
21,980 KB
testcase_15 AC 3 ms
6,548 KB
testcase_16 AC 28 ms
8,160 KB
testcase_17 AC 137 ms
21,984 KB
testcase_18 AC 3 ms
6,548 KB
testcase_19 AC 15 ms
7,644 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 29 ms
9,692 KB
testcase_22 AC 8 ms
6,548 KB
testcase_23 AC 368 ms
6,548 KB
testcase_24 AC 254 ms
6,676 KB
testcase_25 AC 367 ms
10,336 KB
testcase_26 AC 1,371 ms
135,272 KB
testcase_27 AC 180 ms
6,676 KB
testcase_28 AC 1,764 ms
135,780 KB
testcase_29 AC 1,805 ms
135,776 KB
testcase_30 AC 1,762 ms
135,796 KB
testcase_31 AC 1,776 ms
135,784 KB
testcase_32 AC 1,731 ms
135,788 KB
testcase_33 AC 345 ms
8,288 KB
testcase_34 AC 325 ms
6,676 KB
testcase_35 AC 598 ms
39,008 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 AC 59 ms
12,256 KB
testcase_38 AC 5 ms
6,676 KB
testcase_39 AC 1,801 ms
135,776 KB
testcase_40 AC 1,806 ms
135,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


int N,M,K;
ll dp[1<<24];
ll A[25];
int G[303030];


ll comb(ll P_,ll Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*(P_--)/i;
	
	return p;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>K;
	FOR(i,M) {
		cin>>s;
		x=0;
		FOR(j,N) if(s[j]=='1') x|=1<<j;
		dp[x]++;
	}
	
	for(i=K;i<=N;i++) {
		A[i]=1;
		for(j=K;j<i;j++) A[i]-=A[j]*comb(i,j);
	}
	
	int mask;
	FOR(i,N) FOR(mask,1<<N) if(mask&(1<<i)) dp[mask^(1<<i)]+=dp[mask];
	FOR(mask,1<<N) dp[mask]*=A[__builtin_popcount(mask)];
	FOR(i,N) FOR(mask,1<<N) if(mask&(1<<i)) dp[mask]+=dp[mask^(1<<i)];
	FOR(i,M+1) G[i]=1<<20;
	
	FOR(mask,1<<N) chmin(G[dp[mask]],__builtin_popcount(mask));
	
	for(i=M-1;i>=0;i--) chmin(G[i],G[i+1]);
	
	for(i=1;i<=M;i++) cout<<G[i]<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0