Codeforces Round #587 (Div. 3) C题 【判断两个矩形是否完全覆盖一个矩形问题】 {补题 [差点上分系列]}
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题 【判断两个矩形是否完全覆盖一个矩形问题】 {补题 [差点上分系列]}的更多相关文章
- 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 ...
- Codeforces Round #587 (Div. 3)
https://codeforces.com/contest/1216/problem/A A. Prefixes 题意大概就是每个偶数位置前面的ab数目要相等,很水,被自己坑了 1是没看见要输出修改 ...
- Codeforces Round #324 (Div. 2) (快速判断素数模板)
蛋疼的比赛,当天忘了做了,做的模拟,太久没怎么做题了,然后C题这么简单的思路却一直卡到死,期间看了下D然后随便猜了下,暴力了下就过了. A.找一个能被t整除的n位数,那么除了<=10以外,其他都 ...
- Codeforces Round #587 (Div. 3) D. Swords
链接: https://codeforces.com/contest/1216/problem/D 题意: There were n types of swords in the theater ba ...
- Codeforces Round #587 (Div. 3) B. Shooting(贪心)
链接: https://codeforces.com/contest/1216/problem/B 题意: Recently Vasya decided to improve his pistol s ...
- Codeforces Round #587 (Div. 3) A. Prefixes
链接: https://codeforces.com/contest/1216/problem/A 题意: Nikolay got a string s of even length n, which ...
- Codeforces Round #587 (Div. 3) F. Wi-Fi(单调队列优化DP)
题目:https://codeforces.com/contest/1216/problem/F 题意:一排有n个位置,我要让所有点都能联网,我有两种方式联网,第一种,我直接让当前点联网,花费为i,第 ...
- 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 ...
- Codeforces Round #587 (Div. 3) F Wi-Fi(线段树+dp)
题意:给定一个字符串s 现在让你用最小的花费 覆盖所有区间 思路:dp[i]表示前i个全覆盖以后的花费 如果是0 我们只能直接加上当前位置的权值 否则 我们可以区间询问一下最小值 然后更新 #incl ...
随机推荐
- Python【BeautifulSoup解析和提取网页数据】
[解析数据] 使用浏览器上网,浏览器会把服务器返回来的HTML源代码翻译为我们能看懂的样子 在爬虫中,也要使用能读懂html的工具,才能提取到想要的数据 [提取数据]是指把我们需要的数据从众多数据中挑 ...
- Mysql slave 延迟故障一列(无主键)
首先还是给出我见过的一些延迟可能: 大事物延迟 延迟略为2*执行时间 状态为:reading event from the relay log 大表DDL延迟 延迟略为1*执行时间 状态为:alter ...
- 2019牛客多校三 A. Graph Games (图分块)
大意: 给定无向图, 定义$S(x)$为$x$的邻接点集合. 每次操作翻转$[L,R]$范围的边, 询问$S(x)$与$S(y)$是否相等. 快速判断集合相等可以用$CF 799F$的技巧. 采用$h ...
- 监听lsnrctl status查询状态报错linux error 111:connection refused
报错现象 今天给客户一个单实例环境配置监听,创建正常,查询状态异常报错 tns tns tns linux error :connection refused 匹配MOS Starting TNS L ...
- Centos6 yum安装nginx
1.Centos6系统库中默认是没有nginx的rpn包的,所以我们需要先更新下rpm依赖库 (1):使用yum安装nginx,安装nginx库 rpm -Uvh http://nginx.org/p ...
- Https请求被中止: 未能创建 SSL/TLS 安全通道
可以参考https://www.cnblogs.com/ccsharp/p/3270344.html 和https://blog.csdn.net/baidu_27474941/article/det ...
- Django rest-framework框架-组件之分页
分页: a. 分页,看第n页, 每页显示n条数据 from rest_framework import serializers from api import models from rest_fra ...
- python实现暴力破解
import urllib2 import urllib import cookielib import threading import sys import Queue from HTMLPars ...
- 搭建nginx静态资源站
搭建静态资源站包括以下几部分: root指令与alias指令的区别 使用gzip压缩资源 如何访问指定目录下的全部资源文件 如何限制访问流量 如何自定义log日志 root指令与alias指令的区别 ...
- 用<audio>标签打造一个属于自己的HTML5音乐播放器
上一章节,我们刚刚讲了<video>标签,今晚,我们讲的是<audio>标签,这两个东东除了表示的内容不一样以外,其他的特性相似的地方真的太多了,属性和用法几乎一样,也就说,如 ...