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
Your program should handle the queries of the following two types:
“1 x y” (x “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.
Input
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 109 by their absolute value.
It’s guaranteed that all queries are correct.
Output
For each query of the second type print “YES” or “NO” on a separate line depending on the answer.
Examples
inputCopy
5
1 1 5
1 5 11
2 1 2
1 2 9
2 1 2
outputCopy
NO
YES
区间的可达及联通问题;
从一个区间到另一个区间,回溯的时候不必将原先标记清零,因为只要有路径可达即可,
#include
#include
#include
#include
#include
#include
#include
#include
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
机房租用,北京机房租用,IDC机房托管, http://www.e1idc.net