Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓
统计

一位朋友买了一块布,绿底白方格。“啊,它看起来像个棋盘!”“对我来说,它更像稿纸。”“它真让我想起绿豆糕。”同一块布,我们每个人看到的却各不相同。每个人对美的视角各异,人们持有不同的观点并没有什么坏处。真正重要的是包容并尊重彼此的视角。

如果一个人能通过门欣赏日出的美景,又何必非要让他走到窗前去听鸟鸣呢?你享受你的鸟鸣,他欣赏他的日出,两人都能同样地体验到美。

你决定去植物园旅行,享受鸟鸣。植物园里有 $n$ 个区域和 $m$ 条小径,第 $i$ 条小径连接第 $u_i$ 个区域和第 $v_i$ 个区域。

植物园中的一条路线定义为一个区域序列 $a_1, a_2, \dots, a_k$,其长度为 $k$,满足以下条件:

  • $k \ge 3$。
  • $\forall i \neq j, a_i \neq a_j$。
  • $\forall 1 \le i < k$,存在一条连接第 $a_i$ 个区域和第 $a_{i+1}$ 个区域的小径。
  • 存在一条连接第 $a_k$ 个区域和第 $a_1$ 个区域的小径。

为了确保每位游客都能同样地体验到美,你决定编写一个程序来检查植物园中所有的路线是否具有相同的长度。如果植物园中不存在任何路线,我们认为所有路线的长度相同。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 5 \times 10^5$),表示测试用例的数量。

在每个测试用例中,第一行包含两个整数 $n, m$ ($1 \le n \le 5 \times 10^5, 0 \le m \le 5 \times 10^5$),分别表示区域的数量和路径的数量。保证在所有 $T$ 个测试用例中,$\sum n, \sum m \le 5 \times 10^5$。

接下来 $m$ 行,第 $i$ 行包含两个整数 $u_i, v_i$ ($1 \le u_i, v_i \le n, u_i \neq v_i$),表示第 $i$ 条小径连接第 $u_i$ 个区域和第 $v_i$ 个区域。保证连接同一对区域的小径最多只有一条。从任何区域出发,都可以通过小径到达其他任何区域。

输出格式

对于每个测试用例,如果所有路线的长度都相同,则输出 Yes,否则输出 No

样例

输入 1

1
5 6
1 2
2 3
3 1
1 4
4 5
5 1

输出 1

Yes

输入 2

2
2 1
1 2
5 6
1 2
2 3
3 1
2 4
3 5
4 5

输出 2

Yes
No

输入 3

2
4 5
1 2
2 3
3 1
2 4
4 1
5 6
1 2
2 3
1 4
1 5
4 3
5 3

输出 3

No
Yes

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.