• 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)(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 (0x1<x2106,0y1<y2106)(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 (0x3<x4106,0y3<y4106)(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 (0x5<x6106,0y5<y6106)(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>
    #include <algorithm>
    #include <string>
    #include <set>
    #include <queue>
    #include <map>
    #include <sstream>
    #include <cstdio>
    #include <cstring>
    #include <numeric>
    #include <cmath>
    #include <iomanip>
    #include <deque>
    #include <bitset>
    #include <unordered_set>
    #include <unordered_map>
    #define ll              long long
    #define PII             pair<int, int>
    #define rep(i,a,b)      for(int  i=a;i<=b;i++)
    #define dec(i,a,b)      for(int  i=a;i>=b;i--)
    using namespace std;
    int dir[4][2] = { { 0,1 } ,{ 0,-1 },{ 1,0 },{ -1,0 } };
    const long long INF = 0x7f7f7f7f7f7f7f7f;
    const int inf = 0x3f3f3f3f;
    const double pi = 3.14159265358979323846;
    const double eps = 1e-6;
    const int mod =1e9+7;
    const int N = 100005;
    //if(x<0 || x>=r || y<0 || y>=c)
    
    inline ll read()
    {
        ll x = 0; bool f = true; char c = getchar();
        while (c < '0' || c > '9') { if (c == '-') f = false; c = getchar(); }
        while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
        return f ? x : -x;
    }
    ll gcd(ll m, ll n)
    {
        return n == 0 ? m : gcd(n, m % n);
    }
    ll lcm(ll m, ll n)
    {
        return m * n / gcd(m, n);
    }
    ll qpow(ll m, ll k, ll mod)
    {
        ll res = 1, t = m;
        while (k)
        {
            if (k & 1)
                res = res * t % mod;
            t = t * t % mod;
            k >>= 1;
        }
        return res;
    }       
    
    int main()
    {
        ll x[7], y[7];
        rep(i, 1, 6)
        {
            cin >> x[i];
            cin >> y[i];
        }
        rep(i, 1, 2)
        {
            if (x[2 * i + 1]<=x[1] && y[2 * i + 1]<=y[1] && x[2 * i + 2]>=x[2] && y[2 * i + 2]>=y[2])
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (x[3] <= x[1] && x[4] >= x[2] && x[5] <= x[1] && x[6] >= x[2])
        {
            if (y[3] <= y[6] && y[4] >= y[2]  && y[5]<=y[1])
            {
                cout << "NO" << endl;
                return 0;
            }
            if (y[5] <= y[4] && y[3] <= y[1] && y[6] >= y[2])
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        if (y[3] <= y[1] && y[4] >= y[2] && y[5] <= y[1] && y[6] >= y[2])
        {
            if (x[3] <= x[6] && x[4] >= x[2] && x[5] <= x[1])
            {
                cout << "NO" << endl;
                return 0;
            }
            if (x[5] <= x[4] && x[3] <= x[1] && x[6] >= x[2])
            {
                cout << "NO" << endl;
                return 0;
            }
        }
        cout << "YES" << endl;
        return 0;
    }
  • 相关阅读:
    中国剩余定理(crt)和扩展中国剩余定理(excrt)
    数论集合
    gcd(欧几里得算法)与exgcd(扩展欧几里得算法)
    青蛙的约会
    【杭电多校第七场】A + B = C
    【XDOJ】小W的塔防
    备战省赛组队训练赛第十四场(UPC)
    2019.4.27浙江省赛
    备战省赛组队训练赛第六场(UPC)
    备战省赛组队训练赛第七场(UPC)
  • 原文地址:https://www.cnblogs.com/dealer/p/13083110.html
Copyright © 2020-2023  润新知