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;
    }
    
  • 相关阅读:
    数据结构 AVL树
    数据结构 快速排序
    Mybatis 传递多个参数
    数据结构 二叉搜索树
    Java 多线程 ReadWriteLock
    Java 基础 集合框架
    SourceTree安装跳过注册
    【前端部署】阿里云 windows2019服务器用node部署静态项目
    【node开发】node简易服务器一分钟搞定
    【node开发】node.js编写一个接口
  • 原文地址:https://www.cnblogs.com/YDDDD/p/11623006.html
Copyright © 2011-2022 走看看