QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 2048 MB 總分: 100

#16080. 雕塑

统计

想象一个由铜板制成的箱子。再想象第二个箱子,它与第一个箱子相交,以及其他几个可能相互相交(或不相交)的箱子。这就是雕塑家 Oto Boxing 创作其雕塑的方式。事实上,他并不亲自进行太多建造工作,他只负责设计;实际的建造工作外包给了一家建筑公司。为了计算建造费用,公司需要知道所用铜板的总面积。当然,一个箱子中被隐藏在另一个箱子内部的部分是不需要用铜板制作的。(铜非常昂贵,而且价格还在上涨。)建造完成后,整个雕塑会被浸入化学药水池中。为了防止药水溢出,建筑公司需要知道该雕塑的总体积。已知一个雕塑是由一组箱子组成的,请你计算该雕塑的表面积和体积。

Oto 的一些设计是连通的,另一些则不是。无论哪种情况,我们都需要知道总面积和总体积。有时,这些箱子可能会完全封闭一个不属于任何箱子内部的空间(参见下面的第二个样例)。由于液体无法进入该封闭空间,因此该空间的体积也必须计入总体积中。当然,包围该空间的铜板是多余的,因此它不计入表面积。

输入格式

第一行包含一个正整数:测试用例的数量,最多为 100。

对于每个测试用例:

  • 一行包含一个整数 $n$ ($1 \le n \le 50$):涉及的箱子数量。
  • $n$ 行,每行包含六个正整数 $x_0, y_0, z_0, x, y, z$ ($1 \le x_0, y_0, z_0, x, y, z \le 500$):三元组 $(x_0, y_0, z_0)$ 是箱子坐标值最小的顶点的坐标,而数字 $x, y, z$ 分别是箱子在 $x$、$y$ 和 $z$ 维度上的尺寸。所有尺寸均以厘米为单位。箱子的各面总是平行于坐标轴。

输出格式

对于每个测试用例:

  • 输出一行,包含两个由单个空格分隔的整数:所需的铜板总面积(单位为 $\text{cm}^2$)和总体积(单位为 $\text{cm}^3$)。

样例

输入 1

2
2
1 2 3 3 4 5
6 2 3 3 4 5
7
1 1 1 5 5 1
1 1 10 5 5 1
1 1 2 1 4 8
2 1 2 4 1 8
5 2 2 1 4 8
1 5 2 4 1 8
3 3 4 1 1 1

输出 1

188 120
250 250

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.