1037. Semiconnected

时间限制 1000 ms   内存限制 32 MB

For a directed graph G = (V, E), if for all pairs of nodes u,v, u can always reach v or v can always reach u , then we call this a Semiconnected graph. Now you are given a directed graph, you should tell us whether it is a Semiconnected graph. If it is, output “yes”, or else“no”.

输入数据

There are several test cases, for each test case, there are two integers in the first line, n and m n(n<=10000) ,m(m<=50000) , means that there are n nodes and m edges in this graph. The nodes are numbered from 1 to n. Then m lines each with two integers u and v means there is an edge from u to v.

输出数据

For each test case, output “yes” if it is a Semiconnected graph, or else “no” instead.

样例输入

复制
4 3
1 2
2 3
3 4
4 3
1 2
2 3
4 3
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n
 · \n

样例输出

复制
yes
no
   \n
  \n

提交

请先 登录

© 2024 FAQs Contact About