PT07Y  Is it a tree
You are given an unweighted, undirected graph. Write a program to check if it's a tree topology.
Input
The first line of the input file contains two integers N and M  number of nodes and number of edges in the graph (0 < N <= 10000, 0 <= M <= 20000). Next M lines contain M edges of that graph  Each line contains a pair (u, v) means there is an edge between node u and node v (1 <= u,v <= N).
Output
Print YES if the given graph is a tree, otherwise print NO.
Example
Input: 3 2 1 2 2 3 Output: YES
hide comments
sonam:
20140202 08:25:13
mai DFS use kar rahi hu to wo to O(2*E) me ho jata hai to phir TLE kyo plz tell me.mai bahut dino se try kar rahi hu 

sonam:
20140202 08:22:23
i am using adjecency list and use DFS.


Shubham Sharma:
20140121 16:41:12
Very Weak test cases ! 

adze:
20140110 23:52:01
@Paul Draper


Bhavik:
20131210 15:00:16
kindly check my solution id:10630933


Avaneesh Rastogi:
20131113 16:31:12
1) The number of nodes should be raised to a million with the same time limit, to reject solutions which apply a suboptimal approach


blc:
20131105 18:43:58
What are the expected answers for the following graphs?


Legolas:
20131104 12:19:57
No need for BFS or DFS, just check if the graph satisfies certain properties (to be exact, 2) and you're good to go! :) 

Sourabh Verma:
20131101 20:55:54
@admin Please delete Rodrigo's comment 

Ouditchya Sinha:
20130726 15:23:05
@Viktor Fonic : Properly written code based on bfs / dfs should give correct output for any test case. My AC code gives "NO" for your test case. :) 
Added by:  ThanhVy Hua 
Date:  20070328 
Time limit:  0.166s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ERL JSRHINO 
Resource:  Coauthor Amber 