QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show] Hackable ✓

#8813. 奇琴伊察的记录

Statistics

欢迎来到坎昆风景优美的海滩和丰富的文化遗产,这里是华为赞助的第二届 Universal Cup 夏季峰会的举办地!在您沉浸于这片海岸天堂的美景时,您也被带回了古代城市奇琴伊察(Chichén Itzá),这是一处著名的玛雅文明遗址,以其宏伟的金字塔以及在天文学和数学方面的先进造诣而闻名。

在奇琴伊察,您发现了一些玛雅文明研究图论的记录。在遗迹中,您找到了一些由古代玛雅人记录的树的度序列。具体来说,一棵树的度序列是该树所有顶点的度数的有序列表。

给定一个度序列,您需要确定是否存在两棵非同构的树对应于该度序列。

回顾一下,我们称 $G_1(V_1, E_1)$ 和 $G_2(V_2, E_2)$ 是同构的,当且仅当存在一个顶点集之间的双射 $\varphi: V_1 \to V_2$ 使得:

$$\forall x, y \in V_1, (x, y) \in E_1 \iff (\varphi(x), \varphi(y)) \in E_2$$

输入格式

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

第一行包含一个整数 $n$ ($2 \le n \le 10^5$),表示树的度序列的长度。

第二行包含 $n$ 个整数 $d_1, d_2, \dots, d_n$,表示度序列。保证存在一棵对应于给定度序列的树。

保证所有测试用例的 $n$ 之和不超过 $2 \times 10^5$。

输出格式

对于每个测试用例,如果存在两棵不同的树对应于给定的度序列,则打印 “Yes”(不含引号),否则打印 “No”(不含引号)。

样例

输入格式 1

3
6
1 1 1 1 3 3
5
1 1 2 2 2
10
1 1 1 1 2 2 2 2 3 3

输出格式 1

No
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.