QOJ.ac

QOJ

Time Limit: 4.0 s Memory Limit: 1024 MB Total points: 100

#8168. 航天器

Statistics

在三维空间中,有 $N$ 颗位于不同坐标处的恒星。第 $i$ 颗恒星位于点 $P_i(x_i, y_i, z_i)$。此外,有一个半径为 $R$ 的球形航天器,以原点为中心。

如果空间中的一点 $p$ 对于所有的 $i = 1, 2, \dots, N$ 同时满足以下条件,则称其为“可爱点”:

  • 从点 $p$ 可以观测到恒星 $i$。换句话说,以 $p$ 和 $P_i$ 为端点的线段不会穿过或接触航天器的表面。

求可爱点所在区域的连通分量个数。具体来说,对于所有可爱点构成的集合 $L$ 以及下面定义的等价关系 $\sim$,确定商集 $L/\sim$ 的大小。

  • 对于 $p_1, p_2 \in L$,$p_1 \sim p_2$ 当且仅当在 $L$ 中存在一条以 $p_1$ 和 $p_2$ 为端点的曲线。

注意,可以证明该值是一个非负整数。 给定 $T$ 组测试数据,请分别求解。

输入格式

输入通过标准输入给出,格式如下:

$T$ $case_1$ $case_2$ $\vdots$ $case_T$

每组测试数据 $case_i$ ($1 \le i \le T$) 的格式如下:

$N \ R$ $x_1 \ y_1 \ z_1$ $\vdots$ $x_N \ y_N \ z_N$

  • 输入中的所有值均为整数。
  • $1 \le T \le 10$
  • $1 \le N \le 500$
  • $1 \le R < \sqrt{x_i^2 + y_i^2 + z_i^2} \le 10^3$ ($1 \le i \le N$)
  • $(x_i, y_i, z_i) \neq (x_j, y_j, z_j)$ ($1 \le i < j \le N$)
  • 答案不受以下操作的影响:
    • 对于 $i = 1, 2, \dots, N$,独立选择一条经过原点的直线 $l_i$ 和一个实数 $\theta_i$ ($|\theta_i| \le 10^{-6}$)。将恒星 $i$ 的位置移动到绕轴 $l_i$ 旋转角度 $\theta_i$ 后得到的位置。

输出格式

输出答案。

样例

样例输入 1

3
4 12
13 0 0
0 15 0
0 -15 0
0 0 15
6 100
0 0 101
0 0 -101
0 101 0
0 -101 0
101 0 0
-101 0 0
20 333
328 -160 -572
-165 417 -847
-319 -45 271
359 -467 -625
-355 -451 658
-280 -424 687
-65 -224 573
475 -371 373
-246 -54 -903
595 -196 -305
622 -570 -250
386 -541 -566
647 455 -424
734 117 -405
830 -10 -393
-334 137 154
74 459 -92
-651 -93 -131
879 148 45
-48 126 -660

样例输出 1

1
0
3

说明

在第一组测试数据中,存在可爱点。

  • 例如,$(0, 0, 100)$ 是一个可爱点。连接该点与给定的 4 个点中任意一点的线段都不会穿过或接触航天器。
  • 此外,$(21, 0, 0)$ 也是一个可爱点。这两个点属于同一个连通分量。

在第二组测试数据中,不存在可爱点。

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.