C. White Sheet

There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle with its sides parallel to the sides of the table. If you will take a look from above and assume that the bottom left corner of the table has coordinates (0,0), and coordinate axes are left and bottom sides of the table, then the bottom left corner of the white sheet has coordinates (x1,y1), and the top right — (x2,y2).

After that two black sheets of paper are placed on the table. Sides of both black sheets are also parallel to the sides of the table. Coordinates of the bottom left corner of the first black sheet are (x3,y3), and the top right — (x4,y4). Coordinates of the bottom left corner of the second black sheet are (x5,y5), and the top right — (x6,y6).

Example of three rectangles.
Determine if some part of the white sheet can be seen from the above after the two black sheets are placed. The part of the white sheet can be seen if there is at least one point lying not strictly inside the white sheet and strictly outside of both black sheets.

Input
The first line of the input contains four integers x1,y1,x2,y2 (0≤x1<x2≤106,0≤y1<y2≤106) — coordinates of the bottom left and the top right corners of the white sheet.

The second line of the input contains four integers x3,y3,x4,y4 (0≤x3<x4≤106,0≤y3<y4≤106) — coordinates of the bottom left and the top right corners of the first black sheet.

The third line of the input contains four integers x5,y5,x6,y6 (0≤x5<x6≤106,0≤y5<y6≤106) — coordinates of the bottom left and the top right corners of the second black sheet.

The sides of each sheet of paper are parallel (perpendicular) to the coordinate axes.

Output
If some part of the white sheet can be seen from the above after the two black sheets are placed, print "YES" (without quotes). Otherwise print "NO".

Input


Output

NO

Input


Output

YES

思路:判断白色矩阵是否四个顶点都在黑色矩阵内,如果不是,直接YES;否则,判断是否白色矩阵被某一个黑色矩阵包含,是就NO,不是的话判断两个黑色矩阵是否相离,是就NO,不是就YES;【借鉴博客的.】

AC代码:

 #include<bits/stdc++.h>

 using namespace std;

 int x1,x2,x3,x4,x5,x6;
int y1,y2,y3,y4,y5,y6;
int check(int x,int y){
int flag=;
if(x>=x3&&x<=x4&&x>=y3&&x<=y4)
flag=;
if(flag){
return flag;
}
if(x>=x5&&x<=x6&&x>=y5&&x<=y6)
flag=;
return flag;
}
int check1(){
int flag=;
if(x1>=x3&&y1>=y3&&x2<=x4&&y2<=y4){
flag=;
}
return flag;
}
int check2(){
int flag=;
if(x1>=x5&&y1>=y5&&x2<=x6&&y2<=y6){
flag=;
}
return flag;
}
int main(){
scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
scanf("%d%d%d%d",&x3,&y3,&x4,&y4);
scanf("%d%d%d%d",&x5,&y5,&x6,&y6);
int a=check(x1,y1);
int b=check(x1,y2);
int c=check(x2,y2);
int d=check(x2,y1);
if(!a||!b||!c||!d){ // 判断是否四边形是否有点没有被覆盖
printf("YES");
return ;
}
if(check1()||check2()){ // 判断是否有矩形可将其完全覆盖的
printf("NO");
return ;
}
if(max(x3,x5)>min(x4,x6)||max(y3,y5)>min(y4,y6)){ // 判断是否矩形分离
printf("YES");
}else{
printf("NO");
}
return ;
}

Codeforces Round #587 (Div. 3) C题 【判断两个矩形是否完全覆盖一个矩形问题】 {补题 [差点上分系列]}的更多相关文章

  1. Codeforces Round #587 (Div. 3) C. White Sheet

    链接: https://codeforces.com/contest/1216/problem/C 题意: There is a white sheet of paper lying on a rec ...

  2. Codeforces Round #587 (Div. 3)

    https://codeforces.com/contest/1216/problem/A A. Prefixes 题意大概就是每个偶数位置前面的ab数目要相等,很水,被自己坑了 1是没看见要输出修改 ...

  3. Codeforces Round #324 (Div. 2) (快速判断素数模板)

    蛋疼的比赛,当天忘了做了,做的模拟,太久没怎么做题了,然后C题这么简单的思路却一直卡到死,期间看了下D然后随便猜了下,暴力了下就过了. A.找一个能被t整除的n位数,那么除了<=10以外,其他都 ...

  4. Codeforces Round #587 (Div. 3) D. Swords

    链接: https://codeforces.com/contest/1216/problem/D 题意: There were n types of swords in the theater ba ...

  5. Codeforces Round #587 (Div. 3) B. Shooting(贪心)

    链接: https://codeforces.com/contest/1216/problem/B 题意: Recently Vasya decided to improve his pistol s ...

  6. Codeforces Round #587 (Div. 3) A. Prefixes

    链接: https://codeforces.com/contest/1216/problem/A 题意: Nikolay got a string s of even length n, which ...

  7. Codeforces Round #587 (Div. 3) F. Wi-Fi(单调队列优化DP)

    题目:https://codeforces.com/contest/1216/problem/F 题意:一排有n个位置,我要让所有点都能联网,我有两种方式联网,第一种,我直接让当前点联网,花费为i,第 ...

  8. Codeforces Round #452 (Div. 2)-899A.Splitting in Teams 899B.Months and Years 899C.Dividing the numbers(规律题)

    A. Splitting in Teams time limit per test 1 second memory limit per test 256 megabytes input standar ...

  9. Codeforces Round #587 (Div. 3) F Wi-Fi(线段树+dp)

    题意:给定一个字符串s 现在让你用最小的花费 覆盖所有区间 思路:dp[i]表示前i个全覆盖以后的花费 如果是0 我们只能直接加上当前位置的权值 否则 我们可以区间询问一下最小值 然后更新 #incl ...

随机推荐

  1. 顺序表添加与删除元素以及 php实现顺序表实例

    对顺序表的操作,添加与删除元素. 增加元素 如下图所示  对顺序列表 Li [1328,693,2529,254]  添加一个元素 111 ,有三种方式: a)尾部端插入元素,时间复杂度O(1);  ...

  2. WUSTOJ 1235: 计算矩阵的鞍点(Java)

    1235: 计算矩阵的鞍点 题目   输出二维数组中行上为最大,列上为最小的元素(称为鞍点)及其位置(行列下标).如果不存在任何鞍点,请输出"404 not found"(不带引号 ...

  3. spring cloud微服务实践七

    在spring cloud 2.x以后,由于zuul一直停滞在1.x版本,所以spring官方就自己开发了一个项目 Spring Cloud Gateway.作为spring cloud微服务的网关组 ...

  4. 使用paypal-php-sdk开发php国际支付

    参考:https://github.com/paypal/PayPal-PHP-SDK/wiki https://blog.csdn.net/markely/article/details/79044 ...

  5. maven项目打包和编译跳过单元测试和javadoc

    代码中可能由于单元测试.注释(方法中的参数)或者maven javadoc插件的问题导致无法打包,影响工作,为避免这两种情况可以在打包时输入命令: mvn clean install -Dmaven. ...

  6. selenium小结

    1.selenium基本使用 https://www.cnblogs.com/andy9468/p/8976930.html 2.url发生跳转的处理 https://www.cnblogs.com/ ...

  7. Image Processing and Analysis_15_Image Registration:A survey of medical image registration——1998

    此主要讨论图像处理与分析.虽然计算机视觉部分的有些内容比如特 征提取等也可以归结到图像分析中来,但鉴于它们与计算机视觉的紧密联系,以 及它们的出处,没有把它们纳入到图像处理与分析中来.同样,这里面也有 ...

  8. Linux学习笔记(十三)磁盘管理(一):磁盘分区

    一.查看磁盘分区使用状况 df [选项] 其中,-l是默认选项 -a 会显示出包括0字节分区在内的所有文件系统分区 -t 后须跟一个参数,这个参数为文件系统的名字,用来在系统中查找属于该文件系统的分区 ...

  9. nginx精准反向代理

    1,完全反向代理,将请求10.130.111.110服务器的请求全部转发到10.130.111.111服务器 location / { proxy_pass http://10.130.111.111 ...

  10. 微信小程序开发(十二)Promise将异步改为同步

    // utils/utils.js /** * requestPromise用于将wx.request改写成Promise方式 * @param:{string} myUrl 接口地址 * @retu ...