1688: [Usaco2005 open]disease manangement disease Management

Source: Internet
Author: User

1688: [Usaco2005 open]disease manangement disease management time limit:5 Sec Memory limit:64 MB
submit:413 solved:275
[Submit] [Status] [Discuss] Description

alas! A set of D (1 <= D <=) diseases (numbered 1..D) is running through the farm. Farmer John would like to milk as many of he n (1 <= n <=) cows as possible. If the milked cows carry more than K (1 <= K <= D) different diseases among them and then the milk would be too contamin Ated and would has to be discarded in its entirety. Please help determine the largest number of cows FJ can milk without have to discard the milk.

Input

* Line 1:three space-separated integers:n, D, and K * Lines 2..n+1:line i+1 describes the diseases of cow I with a list of 1 or more space-separated integers. The first integer, D_i, is the count of cow I ' s diseases; The next d_i integers enumerate the actual diseases. Of course, the list is an empty if D_i is 0. There are n cows, they may have a D disease, and now choose several heads from these cows, but the selected cows are not in the set of diseases more than the K-type disease.

Output

* Line 1:m, the maximum number of cows which can is milked.

Sample Input6 3 2
0---------The first cow with 0 kinds of disease
1 1------The second cow suffers from a disease, the first disease.
1 2
1 3
2 2 1
2 2 1
Sample Output5

OUTPUT DETAILS:

If FJ Milks Cows 1, 2, 3, 5, and 6, then the milk would has only
Diseases (#1 and #2), which is no greater than K (2).

HINT Source

Silver

The problem: In fact, the first thought is very complex, even the tree array have tried to use, but later found that it seems to be 15 kinds of diseases, it is easy to do-directly 01 state compression, and then enumerate the various states (Hansbug: In fact, the state of the disease only need to keep just good k disease can, Even fewer diseases can be cut off, think about why ^_^, and then a variety of bit operations, and then a out of the DA

1/**************************************************************2Problem:16883 User:hansbug4 language:pascal5 result:accepted6Time: theMs7Memory:4132KB8****************************************************************/9  Ten var One I,j,k,l,m,n,x,ans:longint; AA:Array[0..1000000] ofLongint; - functionmin (x,y:longint): Longint; -          begin the               ifX<y ThenMin:=xElsemin:=y; -          End; - functionMax (x,y:longint): Longint; -          begin +               ifX>y ThenMax:=xElsemax:=y; -          End; + begin AREADLN (n,m,l); L:=min (l,m); ans:=0; at       fori:=1  toN Do -          begin -a[i]:=0; - read (k); -                forj:=1  toK Do -                   begin in read (x); -A[i]:=a[i]or(1SHL (X-1)); to                   End; + Readln; -          End; the       fori:=0  toTRUNC (exp (LN (2) *m)-1) Do *          begin $j:=i;k:=0;Panax Notoginseng                whileJ>0  Do -                     begin theInc (K,JMoD 2); +J:=jDiv 2; A                     End; the               ifK<>l Thencontinue;k:=0; +                forj:=1  toN Do if(IorA[J]) =i ThenInc (k); -ans:=Max (ans,k); $          End; $ writeln (ans); - End.

1688: [Usaco2005 open]disease manangement disease Management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.