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
wherecmdis eitherIfor "insert", orQfor "query", orEfor "end"; andnumis an integer coordinate of a point on the -axis. It is guaranteed thatnumis 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 (Enot included) is no more than .
输出格式
For eachIcase, insertnuminto . For eachQcase, output the smallest open interval that containsnumin the format(s1, s2), where boths1ands2must be in . On the other hand, ifnumis no larger than the smallest point in ,s1shall be replaced by-inf, representing negative infinity; or ifnumis no smaller than the largest point in ,s2shall 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)