CF902A.Visiting a Friend
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.

Determine if Pig can visit the friend using teleports only, or he should use his car.
小猪正在拜访一位朋友。
小猪的家位于数轴上的点 0,而他朋友的家位于数轴上的点 m。
小猪可以借助传送门沿数轴移动。
要使用一个传送门,小猪必须先到达该传送门所在的位置,然后选择前往的目标位置:每个传送门都有一个它能将小猪传送至的最右端点,这个点被称为该传送门的限制点。
形式化地,一个位于点 x、限制点为 y 的传送门,可将小猪从点 x 传送到闭区间 [x,y] 内的任意一点(包含端点)。

请判断小猪是否仅通过传送门就能到达朋友家;若不能,则他必须开车前往。
输入格式
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).
第一行包含两个整数 n 和 m(1≤n≤100,1≤m≤100)——分别表示传送门的数量以及朋友家的位置。
接下来的 n 行描述了各个传送门的信息。
其中第 i 行包含两个整数 ai 和 bi(0≤ai≤bi≤m),其中 ai 表示第 i 个传送门的位置,bi 表示其作用范围限制。
保证对每个 i(2≤i≤n)均有 ai≥ai−1。
输出格式
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).
如果存在一条仅使用传送门从佩格的家到他朋友家的路径,则输出 “YES”,否则输出 “NO”。
你可以以任意大小写(大写或小写)输出每个字母。
输入输出样例
输入#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 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:

You can see that there is no path from Pig's house to his friend's house that uses only teleports.
第一个示例如下图所示:

小猪可以从他的家(位置 0)使用第一个传送点到达位置 2,再使用第二个传送点从位置 2 到达位置 3,接着使用第三个传送点从位置 3 到达位置 5(即他朋友的住所)。
第二个示例如下图所示:

可以看出,不存在一条仅通过传送点从小猪家到达他朋友家的路径。
输入解题思路,AI测评打分。不知道怎么写?