QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#1075. 3D 打印机

Statistics

3D 打印是一种通过数字模板制造物品的技术。打印机铺设一层层聚合物材料,将整个 3D 物体构建为一系列形状各异、相互堆叠的扁平板。聚合物最初具有足够的粘性,使得堆叠在一起的板能够粘合。在物体干燥或固化后,最终形成的物体可以非常耐用。

考虑一台 3D 打印机,其待打印的物体由一个模板描述,该模板由多个凸多面体组合而成(即表面平坦的物体,使得从一个内部点到另一个内部点的连线永远不会超出物体的体积)。编写一个程序,确定从给定模板雕刻物体所需的聚合物总体积。

输入格式

输入包含多个测试用例。每个测试用例以一行包含一个整数 $n$ ($1 \le n \le 100$) 开始,表示该模板中多面体的数量。

随后的行描述这 $n$ 个多面体。每个多面体以一行包含一个整数 $f$ ($3 < f < 30$) 开始,这是该多面体的面数。接下来是描述构成这些面的多边形的行。每一行以一个整数 $v$ ($3 \le v \le 24$) 开始,表示顶点数。在同一行中,$v$ 之后会有 $3 \times v$ 个实数,表示 $v$ 个顶点的 $(x, y, z)$ 坐标。例如,如果 $v=3$,则该行将是:

$v \ x_1 \ y_1 \ z_1 \ x_2 \ y_2 \ z_2 \ x_3 \ y_3 \ z_3$

所有坐标均在范围 $[-100, 100]$ 内。顶点按顺序给出;多边形存在从 $(x_1, y_1, z_1)$ 到 $(x_2, y_2, z_2)$,从 $(x_2, y_2, z_2)$ 到 $(x_3, y_3, z_3)$ 的边,依此类推。多边形是闭合的,因此隐含了一条从最后一个顶点回到第一个顶点的边。一个面的所有顶点都将共面。边不会交叉,且每个顶点恰好位于两条边上。多边形中没有三个(或更多)顶点是共线的。

给定测试用例中的任何多面体都不会重叠。输入以一行包含单个 $0$ 结束。

输出格式

对于每个模板,在单独的一行上打印一个实数,表示以立方厘米为单位所需的聚合物体积。体积应保留两位小数,四舍五入。不要打印任何空格。不要在答案之间打印任何空行。

样例

输入 1

2
6
4 10 10 0 10 15 0 15 15 0 15 10 0
4 10 10 0 10 15 0 10 15 20 10 10 20
4 10 15 0 15 15 0 15 15 20 10 15 20
4 15 15 0 15 10 0 15 10 20 15 15 20
4 10 10 0 15 10 0 15 10 20 10 10 20
4 10 10 20 10 15 20 15 15 20 15 10 20
6
4 0 0 0 0 25 0 25 25 0 25 0 0
4 0 0 0 0 25 0 0 25 0.5 0 0 0.5
4 0 25 0 25 25 0 25 25 0.5 0 25 0.5
4 25 25 0 25 0 0 25 0 0.5 25 25 0.5
4 25 0 0 0 0 0 0 0 0.5 25 0 0.5
4 0 0 0.5 0 25 0.5 25 25 0.5 25 0 0.5
0

输出 1

812.50

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.