P28946 [洛谷] [AHOI2013] Cube
提高+
题目描述

Problem Description

In a three-dimensional space, there are $N$ cubes. The $i$-th cube occupies the positions from $x_{i_1}, y_{i_1}, z_{i_1}$ to $x_{i_2}, y_{i_2}, z_{i_2}$. These $N$ cubes may intersect or overlap, forming a large geometric shape. Now, calculate the external surface area of this geometric shape.

Input Format

The first line contains an integer $N$, representing the number of cubes.

From the second line to the $N+1$-th line, each line contains 6 integers separated by spaces, representing $x_1, y_1, z_1, x_2, y_2, z_2$.

Output Format

A single line containing an integer, representing the size of the external surface area.

Sample Input and Output

Sample Input #1

1
0 0 0 1 1 1

Sample Output #1

6

Sample Input #2

2
0 1 0 3 2 1
1 0 0 2 3 1

Sample Output #2

22

Notes

All data $\in [0, 200]$.

$x_1 \leq x_2$

$y_1 \leq y_2$

$z_1 \leq z_2$

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 0 0 0 1 1 1
样例输出
6