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), and coordinate axes are left and bottom sides of the table, then the bottom left corner of the white sheet has coordinates (x1,y1)(x1,y1), and the top right — (x2,y2)(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)(x3,y3), and the top right — (x4,y4)(x4,y4). Coordinates of the bottom left corner of the second black sheet are (x5,y5)(x5,y5), and the top right — (x6,y6)(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,y2x1,y1,x2,y2 (0≤x1<x2≤106,0≤y1<y2≤106)(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,y4x3,y3,x4,y4 (0≤x3<x4≤106,0≤y3<y4≤106)(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,y6x5,y5,x6,y6 (0≤x5<x6≤106,0≤y5<y6≤106)(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

Copy

2 2 4 4
1 1 3 5
3 1 5 5

output

Copy

NO

input

Copy

3 3 7 5
0 0 4 6
0 0 7 4

output

Copy

YES

input

Copy

5 2 10 5
3 1 7 6
8 1 11 7

output

Copy

YES

input

Copy

0 0 1000000 1000000
0 0 499999 1000000
500000 0 1000000 1000000

output

Copy

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)(6.5,4.5) lies not strictly inside the white sheet and lies strictly outside of both black sheets.

 

 

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

struct Rect {
    ll x1, y1, x2, y2;

    ll area() const {
        if (x2 < x1 || y2 < y1) return 0;
        else return (x2 - x1) * (y2 - y1);
    }
};
Rect its(Rect a, Rect b) {
    Rect res;
    res.x1 = max(a.x1, b.x1);
    res.x2 = min(a.x2, b.x2);
    res.y1 = max(a.y1, b.y1);
    res.y2 = min(a.y2, b.y2);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    Rect w, b1, b2;
    cin >> w.x1 >> w.y1 >> w.x2 >> w.y2;
    cin >> b1.x1 >> b1.y1 >> b1.x2 >> b1.y2;
    cin >> b2.x1 >> b2.y1 >> b2.x2 >> b2.y2;

    ll res = w.area() - its(w, b1).area() - its(w, b2).area() + its(w, its(b1, b2)).area();
    if (res > 0) cout << "YES\n";
    else cout << "NO\n";
}

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), and coordinate axes are left and bottom sides of the table, then the bottom left corner of the white sheet has coordinates (x1,y1)(x1,y1), and the top right — (x2,y2)(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)(x3,y3), and the top right — (x4,y4)(x4,y4). Coordinates of the bottom left corner of the second black sheet are (x5,y5)(x5,y5), and the top right — (x6,y6)(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,y2x1,y1,x2,y2 (0≤x1<x2≤106,0≤y1<y2≤106)(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,y4x3,y3,x4,y4 (0≤x3<x4≤106,0≤y3<y4≤106)(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,y6x5,y5,x6,y6 (0≤x5<x6≤106,0≤y5<y6≤106)(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

Copy

2 2 4 4
1 1 3 5
3 1 5 5

output

Copy

NO

input

Copy

3 3 7 5
0 0 4 6
0 0 7 4

output

Copy

YES

input

Copy

5 2 10 5
3 1 7 6
8 1 11 7

output

Copy

YES

input

Copy

0 0 1000000 1000000
0 0 499999 1000000
500000 0 1000000 1000000

output

Copy

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)(6.5,4.5) lies not strictly inside the white sheet and lies strictly outside of both black sheets.

原文地址:https://www.cnblogs.com/Shallow-dream/p/11565825.html

时间: 2024-08-03 04:50:17

White Sheet (矩形面积模板) (Codeforces Round #587 (Div. 3) )的相关文章

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 w

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

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 #248 (Div. 1)——Nanami&amp;#39;s Digital Board

题目连接 题意: 给n*m的0/1矩阵,q次操作,每次有两种:1)将x,y位置值翻转 2)计算以(x,y)为边界的矩形的面积最大值 (1?≤?n,?m,?q?≤?1000) 分析: 考虑以(x,y)为下边界的情况,h=(x,y)上边最多的连续1的个数.那么递减的枚举,对于当前hx,仅仅须要看两側能到达的最远距离,使得h(x,ty)不大于h就可以.之后的枚举得到的两側距离大于等于之前的,所以继续之前的两側距离继续枚举就可以. const int maxn = 1100; int n, m, q;

贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

题目传送门 1 /* 2 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 3 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <cstring> 8 #include <cmath> 9 using namespace std; 10 11 typedef long long ll; 12 13 co

Codeforces Round #248 (Div. 1)——Nanami&#39;s Digital Board

题目连接 题意: 给n*m的0/1矩阵,q次操作,每次有两种:1)将x,y位置值翻转 2)计算以(x,y)为边界的矩形的面积最大值 (1?≤?n,?m,?q?≤?1000) 分析: 考虑以(x,y)为下边界的情况,h=(x,y)上边最多的连续1的个数.那么递减的枚举,对于当前hx,只需要看两侧能到达的最远距离,使得h(x,ty)不大于h即可.之后的枚举得到的两侧距离大于等于之前的,所以继续之前的两侧距离继续枚举即可. const int maxn = 1100; int n, m, q; int