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. # VsCode 配置C++调试运行

    VsCode 配置C++调试运行 打开命令面板快捷键为F1,软件上写的Ctrl+Shift+P似乎没用 先安装插件使得可以运行 先自行在vsc扩展中搜索C++安装C/C++插件 再参考知乎专栏中安装c ...

  2. python学习-25 函数递归

    递归 例如: def abc(n): print(n) if int(n/2) == 0: return n return abc(int(n/2)) abc(10) 运行结果: 10 5 2 1 P ...

  3. PHP正则 正向预查&反向预查

    了解正向预查&反向预查前,我们先要知道正则的2个函数:preg_match_all . preg_replace preg_match_all 可以看文章:点击查看 preg_replace ...

  4. 使用Duilib开发Windows软件(4)——消息传递

    云信Duilib中没有窗体类的函数可以用来直接收取到所有控件的事件,每个控件都可以单独设置自己的事件处理函数,一般在InitWindow方法中初始化各个控件的事件处理函数. 每个控件都有许多形如Att ...

  5. Scratch编程:牛顿的苹果——地心引力

    牛顿的苹果 同学们,你们知道牛顿的苹果的故事吗? 传说1665年秋季,牛顿坐在自家院中的苹果树下苦思着行星绕日运动的原因.这时,一只苹果恰巧落下来,它落在牛顿的脚边.就是这个偶尔的瞬间,牛顿发现了苹果 ...

  6. (转)从0移植uboot(六) _实现网络功能

    ref:https://www.cnblogs.com/xiaojiang1025/p/6500532.html 为uboot添加网卡功能可以让uboot通过tftp下载内核, 方便我们的开发, 对于 ...

  7. C# 中类的成员有哪些?

    类(class)是C#类型中最基础的类型.类是一个数据结构,将状态(字段)和行为(方法和其他函数成员)组合在一个单元中.类提供了用于动态创建类实例的定义,也就是对象(object).类支持继承(inh ...

  8. Python练习_函数进阶_day10

    1. 1.作业 1,写函数,接收n个数字,求这些参数数字的和.(动态传参) 2,读代码,回答:代码中,打印出来的值a,b,c分别是什么?为什么? a=10 b=20 def test5(a,b): p ...

  9. #LOF算法

    a.每个数据点,计算它与其他点的距离 b.找到它的K近邻,计算LOF得分 clf=LocalOutlierFactor(n_neighbors=20,algorithm='auto',contamin ...

  10. SmartEvent with kbmMW #1

    前言 前面的文章,我写了有关SmartBinding框架方面的内容.SmartBinding的目的是将数据容器绑定到一起,通常情况下,数据容器可以是显示数据或与数据交互的控件(Edit,ListVie ...