#P15100. [ICPC 2025 LAC] Festival Signs
[ICPC 2025 LAC] Festival Signs
题目描述
During a festival, advertisement signs are added to and removed from a stage at different moments. Each sign has a rectangular shape and is placed perpendicular to the ground, with one side resting firmly on the ground.
A webcam is livestreaming the festival, showing a 2D image of the stage. In this image, the bottom border corresponds to the ground. Each sign covers a rectangular area in the image. A sign is described by an interval and a height , meaning it covers all points of the image where and .
Note that the sign covers the points on the bottom and side borders of the rectangle, but not the top border. Besides, rectangles representing different signs may overlap.
During the livestream, the manager will make several queries at different moments. Each query specifies an interval , and asks for the minimum height among all uncovered points with , with and being real numbers.
Your task is to write a program to process a sequence of events: sign additions, sign removals, and queries about the minimum uncovered height over a given interval.
As an example, consider the following sequence of events given in chronological order (see picture below):
- Sign with and is added.
- Sign with and is added.
- Query is made. The answer to this query is . An uncovered point with minimum height within the interval is, for instance, the point with coordinates .
- Query is made, with answer .
- Query is made, with answer .
- Second added sign is removed.
- Query is made, with answer . Note that the removal of the second added sign changed the answer of query .
:::align{center}
:::
输入格式
The first line contains an integer () indicating the number of events.
Each of the next lines describes an event, in chronological order. The content of the line depends on the event, as follows:
- Sign addition: the line contains the character “+” (plus sign) and three integers , and ( and ), representing that a sign is added, covering a rectangle of the image as explained in the statement. Each added sign is assigned a sequential integer identifier, starting from .
- Sign removal: the line contains the character “-” (minus sign) and an integer , indicating that the sign with identifier is removed. It is guaranteed that identifies an added and not previously removed sign.
- Query: the line contains the character “?” (question mark) and two integers and (), asking for the minimum uncovered height within the interval , as explained in the statement. It is guaranteed that the input contains at least one query.
输出格式
Output a line for each query, with an integer indicating the minimum uncovered height within the corresponding interval.
7
+ 2 5 3
+ 4 7 5
? 1 10
? 2 7
? 4 5
- 2
? 4 5
0
3
5
3
4
+ 1 2 1
+ 3 4 1
? 1 2
? 1 4
1
0