QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100
統計

Dingdong 计划前往 Hamu 国旅行。

Hamu 国由 $n$ 个城市和 $m$ 条双向道路组成。在这次旅行之前,Dingdong 已经访问过城市 $i$ 恰好 $a_i$ 次。在这次旅行中,Dingdong 计划从城市 $s$ 进入 Hamu 国。在接下来的每一天,Dingdong 将沿着某条道路前往一个城市并访问该城市一次。在最后一天的访问结束时,Dingdong 应该位于城市 $s$ 并从城市 $s$ 离开 Hamu 国。请注意,在进入 Hamu 国的那天,Dingdong 并不访问城市 $s$。

Dingdong 希望在这次旅行之后,结合他之前的访问记录,Hamu 国的每个城市都被他访问了偶数次。Dingdong 的时间有限,在这次旅行中最多只能访问 $5n$ 个城市。请帮助他构建一个可行的旅行计划,或者告诉他这是否是不可能的。

输入格式

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

对于每个测试用例,第一行包含三个整数 $n, m, s$($1 \le n \le 2 \times 10^5, 0 \le m \le 2 \times 10^5, 1 \le s \le n$),其中 $n$ 是城市数量,$m$ 是道路数量,$s$ 是起点城市的编号。

下一行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$($0 \le a_i \le 10^9$),表示 Dingdong 之前访问每个城市的次数。

接下来的 $m$ 行每行包含两个整数 $u_i, v_i$($1 \le u_i, v_i \le n$),表示连接城市 $u_i$ 和城市 $v_i$ 的一条无向道路。可能存在重边和自环。换句话说,不保证 $u_i \neq v_i$,也不保证对于 $i \neq j$ 有 $(u_i, v_i) \neq (u_j, v_j)$。

保证所有测试用例中 $n$ 的总和以及 $m$ 的总和分别不超过 $2 \times 10^5$。

输出格式

对于每个测试用例,如果不存在可行的旅行计划,则在一行中输出 No

否则,首先在一行中输出 Yes,然后在下一行输出一个整数 $k$($0 \le k \le 5n$),表示这次旅行中的总访问次数。在接下来的一行中,按顺序输出访问的城市编号。

样例

输入样例 1

5
4 4 1
1 1 1 1
1 2
2 3
3 4
4 1
5 7 1
9 4 3 11 7
1 2
2 5
2 4
3 4
2 3
1 3
4 5
2 2 2
114 514
1 2
1 2
5 0 1
114 514 19 19 810
2 1 1
3 5
1 2

输出样例 1

Yes
4
2 3 4 1
Yes
6
2 4 5 2 3 1
Yes
0

No
Yes
2
2 1

说明

对于第一个测试用例,沿着路线 $1 \to 2 \to 3 \to 4 \to 1$ 访问后,城市 $1, 2, 3, 4$ 分别被访问了 $2, 2, 2, 2$ 次,满足要求。

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.