K. A-4 The Smallest Open Interval

    传统题 500ms 512MiB

A-4 The Smallest Open Interval

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Given a set SS of points on the xx -axis. For any point pp , you are suppose to find the smallest open interval that contains pp , provided that the two ends of the interval must be in SS .

输入格式

Each input file contains one test case. Each case consists of several lines of commands, where each command is given in the format:

cmd num  

wherecmdis eitherIfor "insert", orQfor "query", orEfor "end"; andnumis an integer coordinate of a point on the xx -axis. It is guaranteed thatnumis in the range [109,109][-10^9, 10^9] .
The input is ended byE. It is guaranteed that there are no more than 10510^5 distinct points in SS , and so is the number of queries. The total number of commands (Enot included) is no more than 3×1053\times 10^5 .

输出格式

For eachIcase, insertnuminto SS . For eachQcase, output the smallest open interval that containsnumin the format(s1, s2), where boths1ands2must be in SS . On the other hand, ifnumis no larger than the smallest point in SS ,s1shall be replaced by-inf, representing negative infinity; or ifnumis no smaller than the largest point in SS ,s2shall be replaced by+inf, representing positive infinity.
It is guaranteed that there must be at least 1 point in SS before the first query.

题目示例数据

I 100
Q 100
I 0
I 33
I -200
Q 25
Q 33
Q -200
Q 200
E
(-inf, +inf)
(0, 33)
(0, 100)
(-inf, 0)
(100, +inf)

PAT2024秋季重现赛

未参加
状态
已结束
规则
IOI
题目
11
开始于
2025-8-3 14:00
结束于
2025-8-3 17:30
持续时间
3.5 小时
主持人
参赛人数
51