There is an
There are three types of coloring operations:
- Color a horizontal line black. Specifically, given two squares
and with , color all squares between (including) these two squares black. - Color a vertical line black. Specifically, given two squares
and with , color all squares between (including) these two squares black. - Color a diagonal line black. Specifically, given two squares
and with and , color all squares with coordinates on the diagonal between these two squares, where . The number of times this type of coloring operation occurs is no more than .
Now you want to know how many black squares there are on the chessboard after performing
Input Specification
The first line of input contains an integer
The second line of input contains three positive integers
Then
Output Specification
Output a line containing an integer, representing the number of black squares on the chessboard that have been colored.
Sample Input 1
0
5 5 3
1 1 3 5 3
2 3 1 3 5
3 1 1 5 5
Sample Output 1
13
Explanation of Sample Output 1
In this sample test, we performed a total of three coloring operations, as shown in the following figure. The state of the chessboard after each of the three operations are given in the order from left to right.
After the first operation, squares
After the second operation, squares
After the third operation,
After all three coloring operations, a total of
Additional Samples
Sample inputs and outputs can be found here.
- Sample 2 (
ex_color2.in
andex_color2.ans
) corresponds to test cases 1-5. - Sample 3 (
ex_color3.in
andex_color3.ans
) corresponds to test cases 6-9. - Sample 4 (
ex_color4.in
andex_color4.ans
) corresponds to test cases 10-13. - Sample 5 (
ex_color5.in
andex_color5.ans
) corresponds to test cases 14-17. - Sample 6 (
ex_color6.in
andex_color6.ans
) corresponds to test cases 18-19. - Sample 7 (
ex_color7.in
andex_color7.ans
) corresponds to test case 20.
Constraints
For all test data, it is guaranteed that:
Test ID | | | Additional Constraints |
---|---|---|---|
| | None | |
| |||
| A | ||
B | |||
None | |||
Additional Constraint A: It is guaranteed that there is only the first type of coloring operation.
Additional Constraint B: It is guaranteed that there are only the first and second type of coloring operation.
Comments