QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 512 MB Points totaux : 100 Hackable ✓

#11723. 我有朋友

Statistiques

英国科学家发现友谊是非常可预测的。他们声称,两个人能够成为朋友,当且仅当他们在各自最喜欢的两种食物中,至少有一种共同的食物。

曼彻斯特的一个著名管弦乐队被选中进行一项科学实验。每位音乐家都被要求选出他们最喜欢的两种不同的食物。

在初步报告中,科学家们公布了根据他们的理论可以成为朋友的音乐家对的完整列表。然而,最喜欢的食物列表尚未公布。

这看起来很可疑,你并不真正信任这种科学研究。你想检查一下这份潜在的友谊列表对于某种食物偏好列表是否是可能的。

输入格式

第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 10^5$; $0 \le m \le 10^5$),分别表示实验组中的音乐家人数和潜在的朋友对数。音乐家的编号为 $1$ 到 $n$。

接下来的 $m$ 行,每行包含两个整数 $a_i$ 和 $b_i$ ($1 \le a_i, b_i \le n$; $a_i \neq b_i$),表示根据科学报告,这两位音乐家有可能成为朋友。

所有无序对 $(a_i, b_i)$ 均不相同。

输出格式

如果无法形成一个不与报告相矛盾的食物偏好列表,输出 “No”。

否则,输出 “Yes”,随后输出 $n$ 对整数 $f_{i,0}$ 和 $f_{i,1}$ ($-10^9 \le f_{i,j} \le 10^9$; $f_{i,0} \neq f_{i,1}$),表示第 $i$ 位音乐家最喜欢的两种食物的标识符。不同的整数对应不同的食物类型。

样例

样例输入 1

7 6
4 2
6 4
2 7
2 6
7 6
3 1

样例输出 1

Yes
58 42
101 202
42 58
303 202
787788 50216
202 404
404 101

样例输入 2

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

样例输出 2

No

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.