GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 31 August 2022

[Solution] Team of Two CodeChef Solution 



Problem

Your class recently got a maths assignment with 5 questions. There are N (\le 20) students in the class and at most 2 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 T, denoting the number of test cases. T test cases follow.

  • Each of the following test cases contains N + 1 lines, where N is the number of students in the class.
    • The first line contains a single integer N.
    • Each of the following N lines contains K_i + 1 positive integers separated by whitespaces.
      • In the i^{th} line, the first positive integer K_i is the number of problems the i^{th} student can solve. The next K_i integers are x_1, x_2, \ldots, x_{K_i}, the indices of the problems this student can solve.

Output Format

The output must consist of T lines.

  • Each line must contain a single string: The solution to the i^{th} test case as a YES or NO (where YES should be returned if some pairing of students is capable of solving all the problems, and NO otherwise).

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

You may print each character of the string in uppercase or lowercase (for example, the strings YESyEsyes, and yeS will all be treated as identical).

Explanation:

Test case 1: There is no student who solved the second question.

Test case 2: 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 3: There is no student who solved fourth and fifth questions.

Test case 4: Given 2 people can collaborate to solve all the problems.

No comments:

Post a Comment