#P10944. Going from u to v or from v to u?

Going from u to v or from v to u?

题目描述

In order to make their sons brave, Jiajia and Wind take them to a big cave. The cave has n rooms, and one-way corridors connecting some rooms. Each time, Wind choose two rooms x and y, and ask one of their little sons go from one to the other. The son can either go from x to y, or from y to x. Wind promised that her tasks are all possible, but she actually doesn't know how to decide if a task is possible. To make her life easier, Jiajia decided to choose a cave in which every pair of rooms is a possible task. Given a cave, can you tell Jiajia whether Wind can randomly choose two rooms without worrying about anything?

输入格式

The first line contains a single integer T, the number of test cases. And followed T cases. The first line for each case contains two integers n, m(0 < n < 1001,m < 6000), the number of rooms and corridors in the cave. The next m lines each contains two integers u and v, indicating that there is a corridor connecting room u and room v directly.

输出格式

The output should contain T lines. Write 'Yes' if the cave has the property stated above, or 'No' otherwise.

题目大意

从u到v还是从v到u?

题目描述

为了让儿子们变得勇敢,Jiajia 和 Wind 带他们去了一个大山洞。这个洞穴有 nn 个房间,还有连接一些房间的单向走廊。每次,Wind 都会选择两个房间 xxyy,并让他们的一个小儿子从一个房间走到另一个房间。儿子可以从 xxyy,也可以从 yyxx。Wind 承诺她的任务都是可能的,但她实际上不知道如何决定一个任务是否可能。为了让她的生活更轻松,Jiajia 决定选择一个洞穴,每一对房间都是一个可能的任务。给定一个洞穴,你能告诉 Jiajia 和 Wind 是否可以随意选择两个房间而不必担心任何事情吗?

输入格式

第一行包含一个整数 TT ,即测试用例的数量。 每种情况的第一行包含两个整数 nmn,m0<n<1001m<6000(0<n<1001,m<6000),洞穴中的房间和走廊数量。接下来的mm行各包含两个整数 uuvv,表示有一条走廊直接连接房间 uu 和房间 vv

输出格式

输出应包含 TT 行。如果洞穴具有上述属性,请写“Yes”,否则写“No”。

1 
3 3 
1 2 
2 3 
3 1
Yes