QOJ.ac

QOJ

حد الوقت: 0.3 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#15685. 璀璨群星

الإحصائيات

小 Bernie 喜欢看天空中的星星。他最喜欢的星座是“纸团星座”(Ball of Paper Constellation),因为它的形状独特且极具辨识度……就像一个揉皱的纸团。

Bernie 从网上下载了一张该星座的照片,现在他想把它打印出来贴在墙上。Bernie 还喜欢看着纸张逐渐从打印机中送出的过程。这一次,他做了一个决定:他希望星星能按亮度非递增的顺序被打印出来。

该星座共有 $N$ 颗星星。对于每颗星星,Bernie 知道它的亮度等级 $B$ 以及它在照片中的 $X$ 和 $Y$ 坐标,其中 $X$ 轴方向向右,$Y$ 轴方向向上。他知道照片是从上到下打印的(即按 $Y$ 坐标递减的顺序),并且同一水平线上的所有内容都会同时被打印出来。

Bernie 的计划可以这样描述:对于任意两颗星星 $S$ 和 $T$,如果 $S$ 比 $T$ 更亮,那么 $S$ 必须在 $T$ 之前或同时被打印。在打印照片之前,Bernie 可以绕任意点将照片旋转任意角度,但他不能对其进行缩放、镜像或变形。现在 Bernie 需要你的帮助,来判断是否存在某种旋转方式,使得星星能够按照他期望的顺序被打印出来。

输入格式

第一行包含一个整数 $N$ ($3 \le N \le 1000$),表示星座中星星的数量。

接下来的 $N$ 行中,每行包含三个整数 $X, Y$ ($-10^4 \le X, Y \le 10^4$) 和 $B$ ($1 \le B \le 1000$),描述一颗星星,其中 $X$ 和 $Y$ 是该星星在照片中的坐标,$B$ 是它的亮度等级。没有两颗星星位于同一位置。

输出格式

输出单行。如果存在某种旋转方式使得星星能够按亮度非递增的顺序打印,则输出大写字母 "Y";否则输出大写字母 "N"。

样例

输入样例 1

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

输出样例 1

Y

输入样例 2

5
0 4 6
2 4 5
3 7 2
4 4 6
3 0 8

输出样例 2

Y

输入样例 3

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

输出样例 3

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.