QOJ.ac

QOJ

実行時間制限: 0.5 s メモリ制限: 2048 MB 満点: 100

#3590. 连接配对

統計

Alexander 和 Melina 是非常好的朋友。在度过了一个充满游戏的漫长夏天后,他们终于要乘巴士回家了。由于这个夏天过得非常充实,他们在巴士旅途中感到很无聊,于是 Alexander 向 Melina 发起了一个最终挑战。

Alexander 给 Melina 一张宽 $W$ 厘米、高 $H$ 厘米的方格纸。这张纸被细分为 $1 \times 1$ 的小方格,形成了一个 $W \times H$ 的坐标系。在纸上,Alexander 画了许多彩色的点,每种颜色恰好有两个点,所有点都位于整数坐标上(可能包括纸的边缘和角落),且没有两个点位于同一个位置。

Alexander 要求 Melina 在每一对同色点之间画一条线,将它们连接起来。连接点的线不能相互接触。然而,这些线可以是任意形状(只要它们保持在纸内),并且可以被视为无限细。

Melina 反驳说这个游戏不公平,因为根本无法满足他的要求。Alexander 向她保证游戏是公平的,她只需要“变强”就能解决这个挑战。经过一番争论,朋友们决定让你这个公正的观察者来判断游戏是否公平。

在上面的例子中,Melina 可以连接每一对点而不使线相交,因此游戏是公平的。相反,在下面的例子中,Melina 无法在不与连接 1 的线相交的情况下连接 2,因此游戏是不公平的。

输入格式

第一行包含两个整数 $W$ 和 $H$ ($1 \le W, H \le 10^9$),分别表示纸的宽度和高度。第二行包含一个整数 $N$ ($1 \le N \le 10^5$),表示画在纸上的点对数。接下来的 $N$ 行中,每行包含四个整数 $X_1, Y_1, X_2$ 和 $Y_2$ ($0 \le X_1, X_2 \le W$ 且 $0 \le Y_1, Y_2 \le H$),表示一对同色点在坐标 $(X_1, Y_1)$ 和 $(X_2, Y_2)$ 处。没有两个点位于同一个位置。

输出格式

如果游戏是公平的,输出一行包含大写字母 “Y”,否则输出大写字母 “N”。

样例

输入格式 1

5 5
3
4 0 2 5
1 0 2 4
4 2 1 2

输出格式 1

Y

输入格式 2

5 5
2
4 0 3 5
5 3 0 2

输出格式 2

N

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.