QOJ.ac

QOJ

実行時間制限: 1.5 s メモリ制限: 256 MB 満点: 100

#12585. Chain & Co.

統計

Chain & Co. 专门生产无限强度的链条。由于其产品质量上乘,市场份额迅速增长。这带来了一些新的挑战,其中一些是他们以前从未想象过的。例如,用计算机程序自动验证链条的耐用性,而这正是你需要编写的程序。

该公司生产大小相等的链环。每个链环都是三维空间中一个无限细的方形框架(由四条无限细的线段组成)。

在测试过程中,所有链环都是轴对齐的$^1$,且放置时没有任何两个框架接触。为了进行适当的强度测试,两组链环 $A$ 和 $B$ 被锻造在一起,使得 $A$ 中的每一个链环都与 $B$ 中的每一个链环不可分离(不可分离意味着如果不破坏其中一个,它们就无法分开)。

你偶然发现了一些链环(轴对齐,两两不相交)。它们处于适当的测试位置吗?换句话说,它们能否被划分为两个非空集合 $A$ 和 $B$,并满足上述要求?

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是各测试用例的描述:

每个测试用例的描述以一个空行开始。下一行包含一个整数 $n$,$1 \le n \le 10^6$,表示链条中链环的数量。接下来的 $n$ 行,每行包含 6 个空格分隔的整数 $x_i, y_i, z_i, x'_i, y'_i, z'_i$,均在 $-10^9$ 到 $10^9$ 之间,表示第 $i$ 个链环的两个对角坐标。

输出格式

对于每个测试用例,输出一行,如果集合处于适当的测试位置,则输出 YES,否则输出 NO

$^1$ 轴对齐意味着所有线段都平行于 X、Y 或 Z 轴。

样例

输入 1

3
2
0 0 0 0 10 10
-5 5 15 5 5 25
5
0 0 0 0 10 10
-5 5 6 5 5 16
-5 5 -6 5 5 4
-5 6 5 5 16 5
-5 -6 5 5 4 5
3
0 0 0 3 0 -3
1 -1 -1 1 2 -4
-1 -2 -2 2 1 -2

输出 1

NO
YES
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.