#icpc2015summerday4g. [icpc2015summer_day4_g]Surface Area of Cubes
[icpc2015summer_day4_g]Surface Area of Cubes
MathJax.Hub.Config({ tex2jax: { inlineMath: [[""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 12px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }
Problem Statement
Taro likes a signle player game "Surface Area of Cubes".
In this game, he initially has an rectangular solid formed by unit cubes (which are all 1 by 1 by 1 cubes). The center of each unit cube is placed at 3-dimensional coordinates where are all integers $(0\\leq x\\leq A-1, 0\\leq y\\leq B-1, 0\\leq z\\leq C-1)$. Then, distinct unit cubes are removed from the rectangular solid by the game master. After the cubes are removed, he must precisely tell the total surface area of this object in order to win the game.
Note that the removing operation does not change the positions of the cubes which are not removed. Also, not only the cubes on the surface of the rectangular solid but also the cubes at the inside can be removed. Moreover, the object can be divided into multiple parts by the removal of the cubes. Notice that a player of this game also has to count up the surface areas which are not accessible from the outside.
Taro knows how many and which cubes were removed but this game is very difficult for him, so he wants to win this game by cheating! You are Taro's friend, and your job is to make a program to calculate the total surface area of the object on behalf of Taro when you are given the size of the rectangular solid and the coordinates of the removed cubes.
Input
The input is formatted as follows.
The first line of a test case contains four integers , and $N (1\\leq A,B,C\\leq 10^8,0\\leq N\\leq \\min \\{1{,}000, A\\times B\\times C-1 \\} ).$
Each of the next lines contains non-negative integers , and which represent the coordinate of a removed cube. You may assume that these coordinates are distinct.
Output
Output the total surface area of the object from which the cubes were removed.
Sample Input 1
2 2 2 1
0 0 0```
### Output for the Sample Input 1
```plain
24```
* * *
### Sample Input 2
```plain
1 1 5 2
0 0 1
0 0 3```
### Output for the Sample Input 2
```plain
18```
* * *
### Sample Input 3
```plain
3 3 3 1
1 1 1```
### Output for the Sample Input 3
```plain
60```
* * *