A-4 The Smallest Open Interval
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Given a set of points on the -axis. For any point , you are suppose to find the smallest open interval that contains , provided that the two ends of the interval must be in .
输入格式
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
wherecmd
is eitherI
for "insert", orQ
for "query", orE
for "end"; andnum
is an integer coordinate of a point on the -axis. It is guaranteed thatnum
is in the range .
The input is ended byE
. It is guaranteed that there are no more than distinct points in , and so is the number of queries. The total number of commands (E
not included) is no more than .
输出格式
For eachI
case, insertnum
into . For eachQ
case, output the smallest open interval that containsnum
in the format(s1, s2)
, where boths1
ands2
must be in . On the other hand, ifnum
is no larger than the smallest point in ,s1
shall be replaced by-inf
, representing negative infinity; or ifnum
is no smaller than the largest point in ,s2
shall be replaced by+inf
, representing positive infinity.
It is guaranteed that there must be at least 1 point in 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)