Micro and Coins
Practice
5 (2 votes)
Approved
Easy
Graphs
Ready
Problem
70% Success 2124 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Micro was playing with a graph gifted to him by his friend on his birthday. The graph contains N vertices and M edges. All the edges are bidirectional. On each vertex of the graph there is a coin. Now Micro has to collect them all. But the game has some rules. The player has to start with some vertex. From current vertex, player can visit only those vertices which are connected to it by an edge. Also if a vertex is visited it cannot be visited again. Now Micro wants to find if he'll be able to collect all the coins.

Input:
First line consists of an integer T denoting the number of test cases.
First line of each test case consists of two space separated integers denoting N and M and the following M lines consists of two space separated integers X and Y denoting there is an edge between vertices X and Y.

Output:
For each test case, if Micro is able to collect all the coins then print "Yes" (without quotes) otherwise print "No" (without quotes).

Constraints:
\( 1 \le T \le 10 \)
\( 1 \le N \le 10 \)
\( 0 \le M \le 100 \)
\( 1 \le X, Y \le N \)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:10
7 votes
Tags:
ApprovedEasyGraphsReady