码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-10-04 21:05:57      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:ict   lse   tps   com   out   rect   cond   bottom   parallel   

链接:

https://codeforces.com/contest/1216/problem/C

题意:

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.

思路:

每次加进来的矩形, 就维护原来的矩形两个位置, 最后判断是否满足即可.

代码:

#include <bits/stdc++.h>
using namespace std;


int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    for (int i = 1;i <= 2;i++)
    {
        int X1, Y1, X2, Y2;
        cin >> X1 >> Y1 >> X2 >> Y2;
        if (x1 >= X1 && x2 <= X2)
        {
            if (y1 >= Y1)
                y1 = max(y1, Y2);
            if (y2 <= Y2)
                y2 = min(y2, Y1);
        }
        if (y1 >= Y1 && y2 <= Y2)
        {
            if (x1 >= X1)
                x1 = max(x1, X2);
            if (x2 <= X2)
                x2 = min(x2, X1);
        }
    }
    if (x1 >= x2 && y1 >= y2)
        puts("NO");
    else
        puts("YES");


    return 0;
}

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

标签:ict   lse   tps   com   out   rect   cond   bottom   parallel   

原文地址:https://www.cnblogs.com/YDDDD/p/11623006.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!