Logo
(追記) (追記ここまで)

34737번 - Festival Signs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6.5 초 2048 MB76583.333%

문제

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 $[A, B]$ and a height $H,ドル meaning it covers all points $(x, y)$ of the image where $A ≤ x ≤ B$ and 0ドル ≤ y < H$.

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 $[L, R],ドル and asks for the minimum height $y ≥ 0$ among all uncovered points $(x, y)$ with $L ≤ x ≤ R,ドル with $x$ and $y$ being real numbers.

Your task is to write a program to process a sequence of $N$ events: sign additions, sign removals, and queries about the minimum uncovered height over a given interval.

As an example, consider the following sequence of $N = 7$ events given in chronological order (see picture below):

  • Sign with $[A, B] = [2, 5]$ and $H = 3$ is added.
  • Sign with $[A, B] = [4, 7]$ and $H = 5$ is added.
  • Query $[1, 10]$ is made. The answer to this query is 0ドル$. An uncovered point with minimum height within the interval is, for instance, the point with coordinates $(1.5, 0)$.
  • Query $[2, 7]$ is made, with answer 3ドル$.
  • Query $[4, 5]$ is made, with answer 5ドル$.
  • Second added sign is removed.
  • Query $[4, 5]$ is made, with answer 3ドル$. Note that the removal of the second added sign changed the answer of query $[4, 5]$.

입력

The first line contains an integer $N$ (1ドル ≤ N ≤ 2 \cdot 10^5$) indicating the number of events.

Each of the next $N$ 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 $A,ドル $B$ and $H$ (1ドル ≤ A, B, H ≤ 10^9$ and $A < B$), 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 1ドル$.
  • Sign removal: the line contains the character “-” (minus sign) and an integer $I ≥ 1,ドル indicating that the sign with identifier $I$ is removed. It is guaranteed that $I$ identifies an added and not previously removed sign.
  • Query: the line contains the character “?” (question mark) and two integers $L$ and $R$ (1ドル ≤ L < R ≤ 10^9$), asking for the minimum uncovered height within the interval $[L, R],ドル 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.

제한

예제 입력 1

7
+ 2 5 3
+ 4 7 5
? 1 10
? 2 7
? 4 5
- 2
? 4 5

예제 출력 1

0
3
5
3

예제 입력 2

4
+ 1 2 1
+ 3 4 1
? 1 2
? 1 4

예제 출력 2

1
0

노트

출처

ICPC > Regionals > Latin America > Latin America Championship > The 2025 ICPC Latin America Championship F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /