3D Blobs#3824

3D Blobs

1 секунд
64 мегабайт
Орташа

You are given a collection of unit cubes whose vertex coordinates are integers. Two cubes with a shared face are glued together. A connected mass of cubes forms a "blob". Your task is to count the number of blobs and find the total surface area of all blobs.

Note: A blob may have internal "bubbles". Its total surface area includes internal wall area of bubbles, as well as area contribution from trapped blobs inside bubbles.

Each unit cube has vertex coordinates (, , ), (, , ), ..., (, , ). (, , ) is called the minimal vertex of a given cube, and is used to specify the cube.

The blobs specified in Test Case 1 are shown below. Some vertexes are labeled:

The example consists of 6 cubes that form 2 blobs. One blob consists of cubes (1, 1, 1), (2, 1, 1), (2, 2, 1) (obscured) and (2, 2, 2); it has a surface area of 18. The other blob consists of cubes (1, 3, 1) and (1, 3, 2); it has a surface area of 10. Therefore, the total surface area is 28.

Кіріс деректері

The first input line contains the number of test cases , 1 \leq N \leq 50.

Each test case begins with an integer , on a single line. lines follow, each containing integers x_i, y_i, and z_i (1 \leq i \leq n) separated by space.

  • is the number of cubes, and satisfies 1 \leq n \leq 100.

  • (x_i, y_i, z_i) is the minimal vertex of cube , and satisfies 1 \leq x_i, y_i, z_i \leq 1000000.

  • All cubes are distinct (within each test case).

Шығыс деректері

For each test case, print the sentence " blobs with area " on a single line, where is the number of blobs, and is the total surface area of the blobs.

Мысалдар

Мысал 1

Loading
Loading