Sereja and Graph
All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Sereja has undirected graph, which consists of n vertexes and m edges. Sereja can delete edges from the graph. Now Sereja is interested in one question : is it possible to delete edges in the graph so that the degree of each vertex in the graph will be equal 1?
Please, help Sereja.
First line contains integer T. T testcases follow. The first line of each testcase contains integers n and m. Following m lines contain descriptions of the edges of the graph, each line contains two numbers — indexes of the vertexes, which are connected with edge. There can be multiple edges in the graph, but can not be any loops.
For each test case print "YES", if you can remove the edges so that the degrees of all vertexes will be equal to 1, and "NO" otherwise. Print the words without quotation marks.
- 1 <= T <= 10
- 1 <= n, m <= 100
Input: 3 2 2 1 2 1 2 3 2 1 2 2 3 4 6 1 2 1 3 1 4 2 3 2 4 3 4 Output: YES NO YES
|Tags||jan14, matching, medium, sereja|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions