显示代码纯文本
#include <iostream>
#include <cstdio>
using std::cin;
using std::cout;
using std::endl;
int dp[65536];
int milks[1024];
bool has_flag(int i,int o){
int base = 1;
base <<= o;
return (i bitand base);
}
int unset_flag(int i,int o){
int base = 1;
base <<= o;
return (i xor base);
}
int set_flag(int i,int o){
int base = 1;
base <<= o;
return (i bitor base);
}
int flag_count(int i){
int cot = 0,base=1;
for(int x=0;x not_eq 16;x++){
if((i bitand base))
cot++;
base <<= 1;
}
return cot;
}
int max(int a,int b){
return (a>b)?a:b;
}
int main(int argc,char ** argv){
freopen("disease.in","r",stdin);
freopen("disease.out","w+",stdout);
int n,d,k,i,p;
int flg ;
int result;
cin>>n>>d>>k;
for(int x=0;x not_eq n;x++,flg = 0){
cin>>i;
while(i--){
cin>>p;
flg = set_flag(flg,--p);
}
milks[x] = flg;
}
int expend = 1;
expend <<= d;
for(int x=0;x not_eq expend;x++){
for(int y=0;y not_eq n;y++){
if((milks[y] bitor x)==x){
dp[x] ++;
}
}
}
for(int x=0;x not_eq expend;x++){
if(flag_count(x)<=k){
result = max(result,dp[x]);
}
}
cout<<result<<endl;
return 0;
}