题号:NC229258
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
Suppose that in a Cartesian coordinate system on an infinite plane, the x-axis represents the ground and there are n rainscreens (We don't consider their thickness.) in the sky.
Every
rainscreen can be described as a segment which starts from the
)
and ends at
)
. Now if it starts to rain from the infinite high sky, I want you to tell me how many units of the x-axis will not get rained on.
To simplify the problem,the rain can only move vertically whenever it falls.
Note that two rainscreens can overlap and intersect with each other, and there is no rainscreen which is placed vertically.
输入描述:
The first line contains one positive integer
.
Each of the next n lines contains four positive integers
, representing a rainscreen which starts from the
and ends at
.
输出描述:
The only one integer - the number of units of the x-axis which will not get rained on.
示例1
输入
复制
5
1 2 2 1
1 1 2 2
3 3 4 3
5 1 6 3
6 3 7 2
备注:
Consider the example, we can draw a picture like below:

It's easy to calculate the answer is 4.