QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓

#10814. 离开 CPC

统计

Little Rabbit 和 Little Horse 已经为大学生程序设计竞赛奋斗了近四年。他们计划今年退役,动物训练队的许多其他成员也是如此。退役意味着离别,而离别总是充满悲伤。如果一名成员的退役会让动物训练队感到悲伤,那么多人同时退役会让每个人都哭泣,并导致无法完成最终的比赛。Little Rabbit 不希望这种情况发生,他让 Little Horse 来管理每场比赛的退役人数。

他们拿到了训练队的名单,并筛选出了今年预计退役的成员名单。名单上的成员要么参加一场比赛,要么参加两场比赛——这是大学生程序设计竞赛的规则。然后,每位想要退役的成员将选择他参加的一场比赛作为退役时间。一场比赛可以用一个元组 $(x, y)$ 来描述,其中 $x$ 代表时间,$y$ 代表地点。为了简化问题,$x$ 和 $y$ 均为正整数,如果两场比赛 $A$ 和 $B$ 满足 $|A.x - B.x| \le d_x$ 或 $|A.y - B.y| \le d_y$,则称它们为“接近”的。如果任意两名成员选择在同一场比赛或两场“接近”的比赛中退役,那么每个人都会非常悲伤并哭泣。

Little Rabbit 和 Little Horse 想知道他们是否可以安排每个人的退役比赛,使得每个人都不会哭泣,从而更好地完成他们的最终比赛。

输入格式

输入包含多个测试用例。 第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试用例的数量。 对于每个测试用例:第一行包含三个整数 $n$ ($1 \le n \le 2 \cdot 10^4$),表示今年将退役的成员人数,$d_x$ 和 $d_y$ ($1 \le d_x, d_y \le 10^9$) 如上所述。接下来的 $n$ 行,第 $i$ 行以一个整数 $k$ ($1 \le k \le 2$) 开头,表示第 $i$ 名成员参加了 $k$ 场比赛。随后是 $k$ 个元组 $(x, y)$ ($1 \le x, y \le 10^9$),每个元组描述了一场比赛的信息。 保证 $n$ 的总和不超过 $10^5$。

输出格式

对于每个测试用例,如果存在一种安排使得每个人都不会哭泣,则输出 Yes,否则输出 No

样例

样例输入 1

3
2 5 5
1 10 10
1 20 20
2 1 1
2 1 1 2 2
2 1 1 2 2
2 1 1
2 1 1 3 3
2 2 2 4 4

样例输出 1

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