传送门

•题意

先给一个白矩阵,再两个黑矩阵

如果两个黑矩阵能把白矩阵包含,则输出NO

否则输出YES

•思路

计算几何题还是思维题呢?

想起了上初中高中做几何求面积的题

这个就类似于那样

包含的话分两种情况讨论,其他的不包含

①白矩形在一个黑矩形内部

  这种情况直接判断边界就可以

②白矩形在两个黑矩形组合的图形内部

  • 首先这个情况的前提是两个黑矩形必须能连接起来
  • 白矩形和两个黑矩形分别会有重合,重合的地方可能会在此重合,

  例如 白矩形(1 1 4 2)   黑1矩形(1 0 3 4)  黑2矩形(2 0 5 3)

    

被黑1黑2矩阵联合包含,与黑1相交面积是粉色区域,与黑2相交面积是绿色区域

但是粉绿色区域的多算的,白矩阵面积=粉色面积+绿色面积-粉绿面积

•代码

 #include<bits/stdc++.h>
using namespace std;
#define ll long long
struct node
{
ll xl,yl,x2,y2;
}a[],p; bool CH(node x,node y )//重合
{
if(x.xl>=y.xl&&x.x2<=y.x2&&x.yl>=y.yl&&x.y2<=y.y2)
return true;
return false;
}
ll XJ(node a,node b)//相交
{
ll cx1=max(a.xl,b.xl);
ll cy1=max(a.yl,b.yl);
ll cx2=min(a.x2,b.x2);
ll cy2=min(a.y2,b.y2);
if(cx1>cx2||cy1>cy2)//不相交 p=node{cx1,cy1,cx2,cy2};//相交矩形
return (cx2-cx1)*(cy2-cy1);//相交面积
} ///包括NO 不包括YES
int main()
{
for(ll i=;i<=;i++)
cin>>a[i].xl>>a[i].yl>>a[i].x2>>a[i].y2; if(CH(a[],a[])||CH(a[],a[]))///重合在内部
{
puts("NO");
return ;
} if(XJ(a[],a[])<) ///2 3不相交
{
puts("YES");
return ;
} if(XJ(a[],a[])>=) ///2 3相交
{
ll s1=XJ(a[],a[]);
node p1=p;
ll s2=XJ(a[],a[]);
node p2=p;
ll s=(a[].y2-a[].yl)*(a[].x2-a[].xl);
s+=max(1ll*,XJ(p1,p2));///重合处会多算 if(s1+s2==s)
{
puts("NO");
return ;
}
else
{
puts("YES");
return ;
}
}
} /**
1 1 4 2
1 0 3 4
2 0 5 3
*/

Codeforces Round #587 C. White Sheet(思维+计算几何)的更多相关文章

  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

    题目链接:Round #587 题目答案:官方Editorial.My Solution A. Prefixes 题意:给一字符串,只含有'a'或'b',需要改变某些位置('a'变'b'或'b'变'a ...

  3. Codeforces Round #587 (Div. 3)

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

  4. 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 ...

  5. Educational Codeforces Round 40 C. Matrix Walk( 思维)

    Educational Codeforces Round 40 (Rated for Div. 2) C. Matrix Walk time limit per test 1 second memor ...

  6. 【CF1256】Codeforces Round #598 (Div. 3) 【思维+贪心+DP】

    https://codeforces.com/contest/1256 A:Payment Without Change[思维] 题意:给你a个价值n的物品和b个价值1的物品,问是否存在取物方案使得价 ...

  7. Codeforces Round #143 (Div. 2) (ABCD 思维场)

    题目连链接:http://codeforces.com/contest/231 A. Team time limit per test:2 seconds memory limit per test: ...

  8. Codeforces Round #395 (Div. 2)(A.思维,B,水)

    A. Taymyr is calling you time limit per test:1 second memory limit per test:256 megabytes input:stan ...

  9. Codeforces Round #416 (Div. 2)(A,思维题,暴力,B,思维题,暴力)

    A. Vladik and Courtesy time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

随机推荐

  1. Leetcode840.Magic Squares In Grid矩阵中的幻方

    3 x 3 的幻方是一个填充有从 1 到 9 的不同数字的 3 x 3 矩阵,其中每行,每列以及两条对角线上的各数之和都相等. 给定一个由整数组成的 N × N 矩阵,其中有多少个 3 × 3 的 & ...

  2. PHPCMS快速建站系列之后台内容自定义修改

    一.后台登录页面 背景图:\statics\images\admin_img 中的 login_bg.jpg 底部版权信息:\phpcms\languages\en 中的 system.lang.ph ...

  3. 如何处理iOS中照片的方向

    使用过iPhone或者iPad的朋友在拍照时不知是否遇到过这样的问题,将设备中的照片导出到Windows上时,经常发现导出的照片方向会有问题,要么横着,要么颠倒着,需要旋转才适合观看.而如果直接在这些 ...

  4. MaxCompute SQL 使用正则表达式选列

    编辑MaxCompute SQL 时,经常会需要在某个表N个列中指定一些列.若需要指定的列比较少,编写SQL时一个个输入既可.当遇到列多的时候,一个个输入就会非常费劲.本文将介绍如何在编写MaxCom ...

  5. 手写call,bind,apply

    //实现call var that = this ; //小程序环境 function mySymbol(obj){ let unique = (Math.random() + new Date(). ...

  6. 用GitHub Pages搭了个博客,欢迎来玩~

    Welcome to visit my new blog https://luoxiaolei.github.io/ Ps. 后续的blog会优先更新到GitHub Pages上.

  7. WPF疑难杂症之二(全屏幕窗口)

    原文:WPF疑难杂症之二(全屏幕窗口) 近日的学习中遇到一个非常奇怪的问题:用XAML文件创建了一个全屏幕窗口,然后,在窗口中建立了一个非常简单的动画.一切都在我的掌控之中,实现非常的顺利. WPF中 ...

  8. Myeclipse 设置默认注释

    windows-->preference-->Java-->Code Style-->Code Templates code-->New Java files ${fil ...

  9. 爬虫:Selenium + PhantomJS

    更:Selenium特征过多(language/UserAgent/navigator/en-US/plugins),以Selenium打开的浏览器处于自测模式,很容易被检测出来,解决方法可选: 用m ...

  10. 洛谷P1164 小A点菜

    //求方案数 定义状态f[i][j] 用前i件物品恰好放够体积为j的背包 方案数 #include<bits/stdc++.h> using namespace std; ; ; int ...