301688: CF320B. Ping-Pong (Easy Version)
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Ping-Pong (Easy Version)
题意翻译
你有一些区间,你可以将区间 $(a, b)$ 移动到区间 $(c, d)$ 当且仅当 c < a < d 或 c < b < d ,如果从区间 $I_1$ 开始存在一个连续的“移动序列”可以到达 $I_2$,那么就有一条从 $I_1$ 到 $I_2$ 的路径。 你需要处理下列两种操作: 1. “1 x y” (x < y),添加一个新区间 $(x, y)$,保证新区间的长度严格大于之前所有区间。 2. “2 a b”,回答询问:是否存在从第 a 个(添加的)区间到第 b 个区间的路径。从 1 开始计数。 注意,最开始没有区间。题目描述
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 $ I_{1} $ from our set to interval $ I_{2} $ from our set if there is a sequence of successive moves starting from $ I_{1} $ so that we can reach $ I_{2} $ . Your program should handle the queries of the following two types: 1. "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. "2 a b" $ (a≠b) $ — answer the question: is there a path from $ a $ -th (one-based) added interval to $ b $ -th (one-based) added interval? Answer all the queries. Note, that initially you have an empty set of intervals.输入输出格式
输入格式
The first line of the input contains integer $ n $ denoting the number of queries, $ (1<=n<=100) $ . Each of the following lines contains a query as described above. All numbers in the input are integers and don't exceed $ 10^{9} $ by their absolute value. It's guaranteed that all queries are correct.
输出格式
For each query of the second type print "YES" or "NO" on a separate line depending on the answer.
输入输出样例
输入样例 #1
5
1 1 5
1 5 11
2 1 2
1 2 9
2 1 2
输出样例 #1
NO
YES