304728: CF902A. Visiting a Friend

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Visiting a Friend

题意翻译

题目描述 小猪准备拜访一位朋友。它的家在数轴上0的位置,它朋友的家在m的位置。小猪通过传送在轴上移动。 当使用传送时,小猪应位于一些特定的传送点之一,并选择目的地。对每个传送点分别有一个限制,传送点不能把小猪送到限制点的右方。 形式上讲,一个位于x,限制是y的传送点可以把小猪从点x传送到闭区间 [x,y]上的任意整点。 判断小猪在仅适用使用传送的情况下能否到达朋友家。 输入输出格式 输入格式: 第一行两个整数n和m(1<=n<=100,1<=m<=100),代表传送点的数量和朋友的家的坐标。 接下来n行包含传送点的信息。 这些行中的第i行包含两个整数ai和bi,0<=ai<=bi<=m,其中ai代表第i个传送点的坐标,bi代表第i个传送点的限制 保证ai>=ai-1(2<=i<=n)。 输出格式: 如果小猪只用传送就可以抵达朋友家,那么输出"YES",否则输出"NO"。 对每个字符,输出其大写或者其小写都可以。(译者:也就是说"YES"和"Yes"甚至"yEs"都算对。) translated by Pantw

题目描述

Pig is visiting a friend. Pig's house is located at point $ 0 $ , and his friend's house is located at point $ m $ 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 $ x $ with limit $ y $ can move Pig from point $ x $ to any point within the segment $ [x;y] $ , including the bounds. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF902A/92bc86959654b1405c61b81d368eac9f5c5fe404.png)Determine if Pig can visit the friend using teleports only, or he should use his car.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ m $ ( $ 1<=n<=100,1<=m<=100 $ ) — the number of teleports and the location of the friend's house. The next $ n $ lines contain information about teleports. The $ i $ -th of these lines contains two integers $ a_{i} $ and $ b_{i} $ ( $ 0<=a_{i}<=b_{i}<=m $ ), where $ a_{i} $ is the location of the $ i $ -th teleport, and $ b_{i} $ is its limit. It is guaranteed that $ a_{i}>=a_{i-1} $ for every $ i $ ( $ 2<=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: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF902A/753e62c3b07259c4bd5318fcbc1770c920417f65.png)Pig can use the first teleport from his house (point $ 0 $ ) to reach point $ 2 $ , then using the second teleport go from point $ 2 $ to point $ 3 $ , then using the third teleport go from point $ 3 $ to point $ 5 $ , where his friend lives. The second example is shown on the picture below: ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF902A/907bb5d428f081e5cfddf9be149837a9d7265e2e.png)You can see that there is no path from Pig's house to his friend's house that uses only teleports.

Input

题意翻译

题目描述 小猪准备拜访一位朋友。它的家在数轴上0的位置,它朋友的家在m的位置。小猪通过传送在轴上移动。 当使用传送时,小猪应位于一些特定的传送点之一,并选择目的地。对每个传送点分别有一个限制,传送点不能把小猪送到限制点的右方。 形式上讲,一个位于x,限制是y的传送点可以把小猪从点x传送到闭区间 [x,y]上的任意整点。 判断小猪在仅适用使用传送的情况下能否到达朋友家。 输入输出格式 输入格式: 第一行两个整数n和m(1<=n<=100,1<=m<=100),代表传送点的数量和朋友的家的坐标。 接下来n行包含传送点的信息。 这些行中的第i行包含两个整数ai和bi,0<=ai<=bi<=m,其中ai代表第i个传送点的坐标,bi代表第i个传送点的限制 保证ai>=ai-1(2<=i<=n)。 输出格式: 如果小猪只用传送就可以抵达朋友家,那么输出"YES",否则输出"NO"。 对每个字符,输出其大写或者其小写都可以。(译者:也就是说"YES"和"Yes"甚至"yEs"都算对。) translated by Pantw

加入题单

算法标签: