2776 looking for representative Yuan
time limit: 1 s
space limit: 256000 KBtitle level: Golden Gold Title Description
Description
Guangzhou second middle Su Yuan Experimental school has a total of n societies, numbered 1 to n respectively.
Guangzhou second middle Su Yuan Experimental school has a total of M individuals, which are numbered 1 to M respectively. Each person may participate in one or more societies, or may not participate in any community.
Each community needs to choose a representative. Brother Qian wants more people to be represented.
Enter a description
Input Description
The first line enters two numbers n and M.
The following n rows have a number of rows per line, and these numbers are positive integers that do not exceed M. Where the number of line I represents all members of the community I. Each line ends with a 0.
Output description
Output Description
The maximum number of people that can be represented is the output.
Sample input
Sample Input
4 4
1 2 0
1 2 0
1 2 0
1 2 3) 4 0
Sample output
Sample Output
3
Data range and Tips
Data Size & Hint
Each test point 1s
Data range
n,m<=200
Category labels
Tags Click here to expand
Puzzle: Bare binary graph matching does not explain
1 type2Point=^node;3Node=Record4 G:longint;5 Next:point;6 End;7 var8 I,j,k,l,m,n:longint;9C,f:Array[0.. +] ofLongint;TenA:Array[0.. +] ofPoint ; One procedureAdd (x,y:longint); inline; A varP:point; - begin - new (p); thep^.g:=y; -p^.next:=A[x]; -a[x]:=p; - End; + functionCheck (x:longint): Boolean;inline; - varP:point; + begin Ap:=A[x]; at whileP<>Nil Do - begin - ifF[p^.g]<>i Then - begin -f[p^.g]:=i; - ifc[p^.g]=0 Then in begin -c[p^.g]:=x; to exit (true); + End - Else ifCheck (C[P^.G]) Then the begin *c[p^.g]:=x; $ exit (true);Panax Notoginseng End; - End; thep:=P^.next; + End; A exit (false); the End; + - {$IFDEF WINDOWS}{$R wiki2776.rc}{$ENDIF} $ $ begin - readln (n,m); - fori:=1 toN Do the begin -a[i]:=Nil;Wuyi while not(EOLN) Do the begin - Read (j); Wu ifj=0 ThenBreak ; - Add (i,j); About End; $ Readln; - End; -Fillchar (C,sizeof (c),0); -Fillchar (F,sizeof (f),0); l:=0; A fori:=1 toN Do + ifCheck (i) ThenInc (L); the Writeln (l); - Readln; $ End. the
Codevs2776 looking for Representative yuan