CF319E.Ping-Pong

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In this problem at each moment you have a set of intervals. You can move from interval (a,b)(a,b) from our set to interval (c,d)(c,d) from our set if and only if c<a<dc < a < d or c<b<dc < b < d . Also there is a path from interval I1I_{1} from our set to interval I2I_{2} from our set if there is a sequence of successive moves starting from I1I_{1} so that we can reach I2I_{2} .

Your program should handle the queries of the following two types:

  1. "1 x y" (x<y) — add the new interval (x,y)(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" (ab)(a≠b) — answer the question: is there a path from aa -th (one-based) added interval to bb -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 nn denoting the number of queries, (1n105)(1 \leq n \leq 10^{5}) . Each of the following lines contains a query as described above. All numbers in the input are integers and don't exceed 10910^{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
    
首页