All Tracks Algorithms Graphs Hamiltonian Path Problem

Micro and Coins
Tag(s):

Graph Theory, Very-Easy

Problem
Editorial
Analytics

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 $$

SAMPLE INPUT
2
3 3
1 2
2 3
1 3
3 2
1 2
2 1
SAMPLE OUTPUT
Yes
No
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic, Kotlin

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications