#P5873. [SEERC 2018] Points and Rectangles
[SEERC 2018] Points and Rectangles
Description
You are given an empty 2D plane and queries. There are two types of queries:
- — Add a point with coordinates to the plane.
- — Add a rectangle whose bottom-left corner is and top-right corner is . The area of the rectangle can be , and the rectangle may degenerate into a point.
Rectangles and points may overlap.
After each query is processed, compute the number of point-rectangle pairs such that the point is inside the rectangle or on its boundary.
Input Format
The first line contains an integer , denoting the number of queries.
The next lines each describe one query:
- — Add a point with coordinates to the plane.
- $2 \ x_1 \ y_1 \ x_2 \ y_2 \ (1 \leq x_1 \leq x_2 \leq 10^9, 1 \leq y_1 \leq y_2 \leq 10^9)$ — Add a rectangle whose bottom-left corner is and top-right corner is .
Output Format
Output lines. The -th line should contain one integer, representing the number of point-rectangle pairs such that the point is inside the rectangle or on its boundary.
5
1 2 3
1 2 2
1 3 4
2 1 1 5 5
2 2 2 2 2
0
0
0
3
4
4
2 1 1 3 3
2 1 1 2 2
1 2 2
1 2 2
0
0
2
4
7
1 5 5
1 5 5
1 5 5
2 2 2 9 9
2 1 1 5 5
2 1 1 2 2
1 2 2
0
0
0
3
6
6
9
Hint
Explanation of the first sample:
After the first query, there is one point on the plane, but there are no rectangles, so there are no valid point-rectangle pairs.
After the second query, there are still no rectangles, so there are still no such pairs.
After the third query, there are still no rectangles.
In the fourth query, we add a rectangle with bottom-left corner and top-right corner . All points added before are inside this rectangle, so there are such pairs.
After the fifth query, we have such pairs: the pairs above, plus new pair where the point inserted in the second query lies inside the rectangle inserted in the fifth query.
Translated by ChatGPT 5
京公网安备 11011102002149号