F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

GT and set

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 612    Accepted Submission(s): 217


Problem Description
You are given $N$ sets.The $i-$th set has $A_i$ numbers.

You should divide the sets into $L$ parts.

And each part should have at least one number in common.

If there is at least one solution,print $YES$,otherwise print $NO$.
 

Input
In the first line there is the testcase $T$ ($T$$\leq$$20$)

For each teatcase:

In the first line there are two numbers $N$ and $L$.

In the next $N$ lines,each line describe a set.

The first number is $A_i$,and then there are $A_i$ distict numbers stand for the elements int the set.

The numbers in the set are all positive numbers and they're all not bigger than $300$.

$1\leq$$N$$\leq30$£¬$1\leq$$L\leq5$£¬$1\leq$$A_i$$\leq10$£¬$1 \leq L \leq N$

You'd better print the enter in the last line when you hack others.

You'd better not print space in the last of each line when you hack others.
 

Output
For each test print $YES$ or $NO$
 

Sample Input
2 2 1 1 1 1 2 3 2 3 1 2 3 3 4 5 6 3 2 5 6
 

Sample Output
NO YES
 

Hint
For the second test,there are three sets:{1,2,3},{4,5,6},{2,5,6}
You are asked to divide into two parts.
One possible solution is to put the second and the third sets into the same part,and put the first in the other part.
The second part and the third part have same number 6.
Another solution is to put the first and the third sets into the same part,and put the second in the other part.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 14:57:37, Gzip enabled