Round #189 (Div.2) B. Ping-Pong (Easy Version)
阿新 • • 發佈:2019-02-11
In this problem at each moment you have a set of intervals. You can move from interval
(a, b) from our set to interval
(c, d) from our set if and only if
c < a < d or
c < b < d. Also there is a path from interval
I1 from our set to interval
I2 from our set if there is a sequence of successive moves starting from
I 1 so that we can reach
I2.
Your program should handle the queries of the following two types:
- "1 x y" (x < y) — add the new interval (x, y) to the set of intervals. The length of the new interval is guaranteed to be strictly greater than all the previous intervals.
- "2 a b" (a ≠ b) — answer the question: is there a path from
a
Answer all the queries. Note, that initially you have an empty set of intervals.