1 $s / 64$ $MB / 100$ points
You are given $N$ rectangles, which are centered in the center of the Cartesian coordinate
system and their sides are parallel to the coordinate axes. Each rectangle is uniquely
identified with its width (along the x-axis) and height (along the y-axis). The lower image
depicts the first sample test.
Mirko has coloured each rectangle in a certain color and now wants to know the area of the
coloured part of the paper. In other words, he wants to know the number of unit squares that
belong to at least one rectangle.
Input
The first line of input contains the integer $N$ (1 ≤ $N$ ≤ 1 000 000), the number of rectangles. Each of the following $N$ lines contains even integers $X$ and $Y$ (2 ≤X, $Y \le 10$^{7}^{}), dimensions
(width and height, respectively) of the corresponding rectangles.
Output
The first and only line of output must contain the required area.
Constraints
In test cases worth 40% of total points, all numbers from the input will be smaller than 3333. In test cases worth 50% of total points, not a single rectangle will be located strictly within another rectangle.
Example 1
1 s / 64 MB / 100 points 3 8 2 4 4 2 6 5 2 10 4 4 2 2 8 8 6 6
output 28 68 Task Ronald 1 s / 64 MB / 120 points There are N cities in one country that are connected with two-way air links. One crazy airline president, Ronald Krump, often changes the flight schedule. More precisely, every day he does the following: ● chooses one of the cities, ● introduces flights from that city towards all other cities where these flights do not currently exist, and at the same time cancels all existing flights from that city For instance, if from city 5 flights exist towards cities 1 and 2, but not towards cities 3 and 4, after Krump’s change, there will exist flights from city 5 towards cities 3 and 4, but not towards cities 1 and 2. The citizens of this country are wondering if a day could come when the flight schedule will be complete. In other words, when between each two different cities a (direct) flight will exist. Write a programme that will, based on the current flight schedule, determine whether it is possible to have a Complete Day , or whether this will never happen, no matter what moves Krump makes.
Example 2
The first line of input contains the integer N (2 ≤ N ≤ 1000), the number of cities. The cities are labeled with numbers from 1 to N . The second line contains the integer M (0 ≤ M < N*(N-1)/2 ), the number of current flights. Each of the following M lines contains two different numbers, the labels of the cities that are currently connected.
The first and only line of output must contain DA (Croatian for “yes”) or NE (Croatian for “no”). SAMPLE TESTS
Example 3
2 0 3 2 1 2 2 3 4 2 1 3 2 4
output output DA NE DA Task Ronald 1 s / 64 MB / 120 points
Clarification of the first test case: In the first step, Krump will introduce the (only possible) line 1-2. Clarification of the third case: If Krump first chooses city 1, flights 1-2, 1-4 and 2-4 will exist. If he then chooses city 3, the flight schedule will become complete.
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.