QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#10343. Division Avoidance

统计

一种新发现的生物可以表示为无限网格上的一组细胞。网格上存在一个坐标系,使得每个细胞都有两个整数坐标 $x$ 和 $y$。坐标为 $x = a$ 和 $y = b$ 的细胞记作 $(a, b)$。

最初,该生物由单个细胞 $(0, 0)$ 组成。随后可以进行零次或多次分裂。在一次分裂中,细胞 $(a, b)$ 被移除,并被两个细胞 $(a + 1, b)$ 和 $(a, b + 1)$ 取代。

例如,第一次分裂后,该生物总是由两个细胞 $(1, 0)$ 和 $(0, 1)$ 组成;第二次分裂后,它要么是三个细胞 $(2, 0)$、$(1, 1)$ 和 $(0, 1)$,要么是三个细胞 $(1, 0)$、$(1, 1)$ 和 $(0, 2)$。

细胞 $(a, b)$ 的分裂仅在细胞 $(a + 1, b)$ 和 $(a, b + 1)$ 尚未成为该生物的一部分时才能发生。例如,如果该生物当前由三个细胞 $(1, 0)$、$(1, 1)$ 和 $(0, 2)$ 组成,则细胞 $(1, 0)$ 不能分裂,因为该分裂产生的结果之一细胞 $(1, 1)$ 已经是该生物的一部分。

给定一组禁止细胞 $(c_i, d_i)$。请问经过零次或多次分裂后,该生物是否可能不包含任何这些禁止细胞?

输入格式

每个测试包含多个测试用例。第一行包含一个整数 $t$ ($1 \le t \le 10\,000$),表示测试用例的数量。接下来是 $t$ 个测试用例的描述。

每个测试用例的第一行包含一个整数 $n$ ($1 \le n \le 10^6$),表示禁止细胞的数量。

接下来的 $n$ 行,每行包含两个整数。第 $i$ 行包含 $c_i$ 和 $d_i$ ($0 \le c_i, d_i \le 10^9$),即第 $i$ 个禁止细胞的坐标。保证所有禁止细胞各不相同。

保证所有测试用例中 $n$ 的总和不超过 $10^6$。

输出格式

对于每个测试用例,如果经过零次或多次分裂后,该生物可能不包含任何禁止细胞,则输出 YES,否则输出 NO。

样例

输入 1

2
4
0 0
1 0
0 1
1 1
16
0 0
0 1
0 2
0 3
1 0
1 1
1 2
1 3
2 0
2 1
2 2
2 3
3 0
3 1
3 2
3 3

输出 1

YES
NO

说明

在第一个测试用例中,按照以下顺序分裂细胞可以创建一个不包含任何禁止细胞的生物:$(0, 0)$, $(1, 0)$, $(1, 1)$, $(0, 1)$, $(2, 1)$, $(2, 2)$, $(1, 2)$, $(1, 1)$。下图展示了该生物在此过程中的变化:

在第二个测试用例中,你可以看到,令人惊讶的是,无论我们进行多少次分裂,任何生物在 $0 \le x, y \le 3$ 的正方形区域内总是至少包含一个细胞。

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.