QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 10

#10639. Malowanie [B]

统计

到了该重新粉刷房子的时间了。Bajtazar 并不喜欢粉刷,但他注意到油漆桶和刷子引起了他孩子们的极大兴趣。于是他把刷子分给了孩子们,并让他们去粉刷其中一面墙。每个孩子粉刷了一个长方形区域,这些长方形的边平行或垂直于地面。

不幸的是,Bajtazar 买的油漆质量并不是最好的,所以现在只有那些被至多一个孩子遗漏的墙面部分看起来还不错。被遗漏指的是该部分没有被某个孩子刷到。请问这些部分的总面积是多少?

输入格式

输入的第一行包含一个整数 $n$($2 \le n \le 500,000$),表示 Bajtazar 的孩子数。

接下来的 $n$ 行,每行描述一个孩子涂刷的区域。在第 $i$ 行中有四个整数 $x_{1}$, $y_{1}$, $x_{2}$, $y_{2}$($0 \le x_{1} < x_{2} \le 10^{9}$, $0 \le y_{1} < y_{2} \le 10^{9}$)。表示第 $i$ 个孩子粉刷了一个左下角为 $(x_{1}, y_{1})$,右上角为 $(x_{2}, y_{2})$,边平行于坐标轴的长方形区域。

输出格式

你的程序应输出一个整数——这部分墙面的面积,不需要再涂刷,也就是说,被至少 $n-1$ 个孩子涂刷过的区域的面积。

示例

输入

3
0 0 5 5
1 0 2 5
0 1 6 3

输出

13

说明

problem_10639_1.gif?

计入答案的区域是图中被涂成较深和最深颜色的区域。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.