[Solution] Team of Two CodeChef Solution
Problem
Your class recently got a maths assignment with questions. There are students in the class and at most people can collaborate. For each student, you know which problems they solved.
Find out if there exists a team of two students who can together solve all problems.
Input Format
The first line of input will contain a single integer , denoting the number of test cases. test cases follow.
- Each of the following test cases contains lines, where is the number of students in the class.
- The first line contains a single integer .
- Each of the following lines contains positive integers separated by whitespaces.
- In the line, the first positive integer is the number of problems the student can solve. The next integers are , the indices of the problems this student can solve.
Output Format
The output must consist of lines.
- Each line must contain a single string: The solution to the test case as a
YES
orNO
(whereYES
should be returned if some pairing of students is capable of solving all the problems, andNO
otherwise).
You may print each character of the string in uppercase or lowercase (for example, the strings YES
, yEs
, yes
, and yeS
will all be treated as identical).
Explanation:
Test case There is no student who solved the second question.
Test case The second student can solve the first question and the first student can solve all the remaining problems, so they can form a team to solve all the problems together.
Test case There is no student who solved fourth and fifth questions.
Test case Given people can collaborate to solve all the problems.
No comments:
Post a Comment