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

原文链接:https://www.cnblogs.com/xwl3109377858/p/11564279.html

Codeforces Round #587 (Div. 3)

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

Examples

input

2 2 4 4

1 1 3 5

3 1 5 5

output

NO

input

3 3 7 5

0 0 4 6

0 0 7 4

output

YES

input

5 2 10 5

3 1 7 6

8 1 11 7

output

YES

input

0 0 1000000 1000000

0 0 499999 1000000

500000 0 1000000 1000000

output

YES

Note

In the first example the white sheet is fully covered by black sheets.

In the second example the part of the white sheet can be seen after two black sheets are placed. For example, the point (6.5,4.5) lies not strictly inside the white sheet and lies strictly outside of both black sheets.

题意:题意就是给你一个白色矩形、两个黑色矩形的左下角和右上角的坐标,

问你这两个黑色矩形是否把白色矩形全部覆盖了,注意是全部覆盖。

思路:刚开始我想的解法就是暴力把白色矩形的四条边上点的坐标判一下是否在两个黑色矩形的任一个之内,

只要有一个点不在就没有全部覆盖,但是在对样例的时候发现,第三个样例对不上,

原来是因为暴力判断边上坐标点少了,不能每次+1仅判断int的坐标,会漏掉一部分,

应该用double的坐标每+0.5判断一下,就可以全部判完,可以自己画图看一下。具体看代码。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<cstring>
 5 #include<algorithm>
 6 #include<map>
 7 #include<set>
 8 #include<vector>
 9 #include<queue>
10 #include<list>
11 #include<stack>
12 using namespace std;
13 #define ll long long
14 const int mod=1e9+7;
15 const int inf=1e9+7;
16
17 //const int maxn=
18
19 double x1,x2,x3,x4,x5,x6;
20
21 double y1,y2,y3,y4,y5,y6;
22
23 inline bool judge1(double x,double y)
24 {
25     if((x>=x3&&x<=x4)&&(y>=y3&&y<=y4))
26         return true;
27     else
28         return false;
29 }
30
31 inline bool judge2(double x,double y)
32 {
33     if((x>=x5&&x<=x6)&&(y>=y5&&y<=y6))
34         return true;
35     else
36         return false;
37 }
38
39 int main()
40 {
41     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
42
43     cin>>x1>>y1>>x2>>y2;
44
45     cin>>x3>>y3>>x4>>y4;
46
47     cin>>x5>>y5>>x6>>y6;
48
49     int flag=0;
50
51     for(double i=x1;i<=x2;i+=0.5)
52     {
53         if((judge1(i,y1)||judge2(i,y1))&&(judge1(i,y2)||judge2(i,y2)))
54             ;
55         else
56         {
57             flag=1;
58             break;
59         }
60      }
61
62      for(double i=y1;i<=y2;i+=0.5)
63      {
64          if((judge1(x1,i)||judge2(x1,i))&&(judge1(x2,i)||judge2(x2,i)))
65             ;
66         else
67         {
68             flag=1;
69             break;
70         }
71      }
72
73     if(flag==0)
74         cout<<"NO"<<endl;
75     else
76         cout<<"YES"<<endl;
77
78     return 0;
79 }

原文地址:https://www.cnblogs.com/xwl3109377858/p/11564279.html

时间: 2024-10-08 18:31:51

Codeforces Round #587 (Div. 3) C - White Sheet的相关文章

Codeforces Round #587 (Div. 3) B - Shooting

原文链接:https://www.cnblogs.com/xwl3109377858/p/11564214.html Codeforces Round #587 (Div. 3) B - Shooting Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed n cans in a row on a ta

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

原文链接:https://www.cnblogs.com/xwl3109377858/p/11564317.html Codeforces Round #587 (Div. 3) D -Swords There were n types of swords in the theater basement which had been used during the plays. Moreover there were exactly x swords of each type. y people

White Sheet (矩形面积模板) (Codeforces Round #587 (Div. 3) )

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)(0,0),

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 coordina

Codeforces Round #587 (Div. 3)

C. White Sheet 一道基础的几何题  给定三个矩形的左下角坐标和右上角坐标,第一块是白色矩形,第二第三都是黑色矩形,问白色矩形是否被黑色矩形完全覆盖.思路就是根据点判断分类讨论. 1.如果白色矩形的四个点没有全部被覆盖了   那么直接输出“NO” 2.如果白色矩形的四个点都被覆盖了,那么就再判断下黑色的矩形有没有交集 1 #include <math.h> 2 #include <stdio.h> 3 #include <stdlib.h> 4 #inclu

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

题意:给定一个字符串s 现在让你用最小的花费 覆盖所有区间 思路:dp[i]表示前i个全覆盖以后的花费 如果是0 我们只能直接加上当前位置的权值 否则 我们可以区间询问一下最小值 然后更新 #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double eps = 1e-6; const int N = 2e5+7; typedef long long ll; const ll mod

Codeforces Round #368 (Div. 2) Brain&#39;s Photos

Brain's Photos Small, but very brave, mouse Brain was not accepted to summer school of young villains. He was upset and decided to postpone his plans of taking over the world, but to become a photographer instead. As you may know, the coolest photos

Codeforces Round #281 (Div. 2) d

/**  * @brief Codeforces Round #281 (Div. 2) d  * @file d.cpp  * @author 闈㈢爜  * @created 2014/12/05 18:19  * @edited  2014/12/05 18:19  * @type  game  *  */ #include <iostream> #include <fstream> #include <cstdlib> #include <stack>

Codeforces Round #597 (Div. 2) A. Good ol&#39; Numbers Coloring

链接: https://codeforces.com/contest/1245/problem/A 题意: Consider the set of all nonnegative integers: 0,1,2,-. Given two integers a and b (1≤a,b≤104). We paint all the numbers in increasing number first we paint 0, then we paint 1, then 2 and so on. Ea