线段包含
Description
给定一个数轴上的两条线段,判断两条线段是否存在覆盖关系。
Input
输入第一行两个整数 a, b(0 <= a < b <= 100000),表示第一条线段的两个端点。输入第一行两个整数 c, d(0 <= c < d <= 100000),表示第二条线段的两个端点。
Output
如果两个线段存在覆盖关系(有可能是第一条覆盖第二条或者第二条覆盖第一条),输出一行"Yes",否则输出一行"No"。
Sample Input 1
1 2
1 4
Sample Output 1
Yes
Sample Input 2
2 4
3 5
Sample Output 2
No
Source
计蒜客
代码:
#include<bits/stdc++.h>
#include<vector>
#include<queue>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(a<=c && b>=d || c<=a && d>=b){
cout<<"Yes";
}
else{
cout<<"No";
}
return 0;
}