P27368 [AtCoder] Monochrome Design
NOI
题目描述

Problem Description

Consider an infinitely large coordinate plane that extends infinitely in all directions (up, down, left, right). Initially, the entire coordinate plane is painted white.
We will perform the following type of query $Q$ times. The $i$-th query is given as follows:

Select the rectangular region with vertices at $ (A_i, B_i) $, $ (A_i, D_i) $, $ (C_i, B_i) $, $ (C_i, D_i) $ and invert the colors within this region. That is, white areas will be painted black, and black areas will be painted white.

After all queries are completed, calculate the area of the region that is painted black.

Input Format

The input is given from the standard input in the following format:

$ Q $ $ A_1 $ $ B_1 $ $ C_1 $ $ D_1 $ $ A_2 $ $ B_2 $ $ C_2 $ $ D_2 $ $ : $ $ A_Q $ $ B_Q $ $ C_Q $ $ D_Q $

Output Format

Output the area of the region painted black after all queries are completed.

Sample Input and Output

Sample Input #1

2
0 0 2 2
1 1 3 3

Sample Output #1

6

Sample Input #2

1
-1000000000 -1000000000 1000000000 1000000000

Sample Output #2

4000000000000000000

Notes/Hints

Constraints

  • $1 \leq Q \leq 10^5$
  • $-10^9 \leq A_i < C_i \leq 10^9$
  • $-10^9 \leq B_i < D_i \leq 10^9$
  • All inputs are integers

Sample Explanation 1

After the first operation, a $2 \times 2$ square region is painted black. After the second operation, the square region enclosed by $ (1,1) $, $ (1,2) $, $ (2,1) $, $ (2,2) $ returns to white, and the final area of the black-painted region is $ 6 $.

Sample Explanation 2

Note that the answer may not fit within a 32-bit integer.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

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