CF902A.Visiting a Friend

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Pig is visiting a friend.

Pig's house is located at point 00 , and his friend's house is located at point mm on an axis.

Pig can use teleports to move along the axis.

To use a teleport, Pig should come to a certain point (where the teleport is located) and choose where to move: for each teleport there is the rightmost point it can move Pig to, this point is known as the limit of the teleport.

Formally, a teleport located at point xx with limit yy can move Pig from point xx to any point within the segment [x;y][x;y] , including the bounds.

Determine if Pig can visit the friend using teleports only, or he should use his car.

输入格式

The first line contains two integers nn and mm ( 1<=n<=100,1<=m<=1001<=n<=100,1<=m<=100 ) — the number of teleports and the location of the friend's house.

The next nn lines contain information about teleports.

The ii -th of these lines contains two integers aia_{i} and bib_{i} ( 0<=ai<=bi<=m0<=a_{i}<=b_{i}<=m ), where aia_{i} is the location of the ii -th teleport, and bib_{i} is its limit.

It is guaranteed that ai>=ai1a_{i}>=a_{i-1} for every ii ( 2<=i<=n2<=i<=n ).

输出格式

Print "YES" if there is a path from Pig's house to his friend's house that uses only teleports, and "NO" otherwise.

You can print each letter in arbitrary case (upper or lower).

输入输出样例

  • 输入#1

    3 5
    0 2
    2 4
    3 5
    

    输出#1

    YES
    
  • 输入#2

    3 7
    0 4
    2 5
    6 7
    

    输出#2

    NO
    

说明/提示

The first example is shown on the picture below:

Pig can use the first teleport from his house (point 00 ) to reach point 22 , then using the second teleport go from point 22 to point 33 , then using the third teleport go from point 33 to point 55 , where his friend lives.

The second example is shown on the picture below:

You can see that there is no path from Pig's house to his friend's house that uses only teleports.

首页