zoukankan      html  css  js  c++  java
  • 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 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;
    }
    
  • 相关阅读:
    .net 命名规范
    解决Swagger刷新后不能保持登录问题
    修改表结构后视图错位问题
    创建.net api文档
    编写.net core tools教程
    VuePress 侧边栏几种配置
    VS 好用快捷键
    Jenkins 修改端口
    获取当前被调用的方法
    遇到异常 add-migration Build failed 解决办法
  • 原文地址:https://www.cnblogs.com/YDDDD/p/11623006.html
Copyright © 2011-2022 走看看