visiting a friend意念传送点

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.
皮格的房子在点0处,他朋友在数轴上的点m处.
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.
正式地说, 一个意念传送点在点x处,有一个限制y,意味着皮格能从点x到任何一个在区间[x,y]的点,包括边界。
Determine if Pig can visit the friend using teleports only, or he should use his car.
请计算出皮格能否只使用意念传送点去拜访他的朋友,否则他应该开他的车。
输入 / Input
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.
第一行包括两个整数n和m(1 ≤ n ≤ 100, 1 ≤ m ≤ 100) - 意念传送点的数量和朋友的坐标
The next n lines contain information about teleports.
接下来n行是关于意念传送点的信息
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.
这些行中的第i行包括两个数a(i)和b(i) (0 ≤ a(i) ≤ b(i) ≤ m), a(i)是第i个传送点的位置,b(i)是它的限制。
It is guaranteed that a(i) ≥ a(i - 1) for every i (2 ≤ i ≤ n). 数据保证对每一个i, a(i) ≥ a(i - 1) (2 ≤ i ≤ n)
输出 / Output
Print “YES” if there is a path from Pig’s house to his friend’s house that uses only teleports, and “NO” otherwise.
输出”YES” 当这里只用传送点有一条路从皮格的家到他朋友那里,否则输出”NO”.
You can print each letter in arbitrary case (upper or lower).
输出不区分大小写
样例 / Example
input1
3 5
0 2
2 4
3 5
output1
YES
input2
3 7
0 4
2 5
6 7
output2
NO

n,m = map(int,input().split())

a =[0]*105
for i in range(n):
    x,y = map(int,input().split())
    a[x+1:y+1] = [1]*(y-x)

for i in range(m):
    if a[i]!=1:
        print('no')
        exit(0)
print('Yes')
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值