zoukankan      html  css  js  c++  java
  • Codeforces Gym 100531G Grave 水题

    Problem G. Grave

    题目连接:

    http://codeforces.com/gym/100531/attachments

    Description

    Gerard develops a Halloween computer game. The game is played on a rectangular graveyard with a
    rectangular chapel in it. During the game, the player places new rectangular graves on the graveyard.
    The grave should completely fit inside graveyard territory and should not overlap with the chapel. The
    grave may touch borders of the graveyard or the chapel.

    Gerard asked you to write a program that determines whether it is possible to place a new grave of given
    size or there is no enough space for it.

    Input

    The first line of the input file contains two pairs of integers: x1, y1, x2, y2 (−109 ≤ x1 < x2 ≤ 109
    ;
    −109 ≤ y1 < y2 ≤ 109
    ) — coordinates of bottom left and top right corners of the graveyard. The second
    line also contains two pairs of integers x3, y3, x4, y4 (x1 < x3 < x4 < x2; y1 < y3 < y4 < y2) —
    coordinates of bottom left and top right corners of the chapel.
    The third line contains two integers w, h — width and height of the new grave (1 ≤ w, h ≤ 109
    ). Side
    with length w should be placed along OX axis, side with length h — along OY axis

    Output

    The only line of the output file should contain single word: “Yes”, if it is possible to place the new grave,
    or “No”, if there is not enough space for it.

    Sample Input

    1 1 11 8

    2 3 8 6

    3 2

    Sample Output

    Yes

    Hint

    题意

    有一个矩形,然后在里面放一个矩阵,问你还能不能再放进去一个w*h的矩阵进去

    题解:

    水题,只有四个空位子,把这四个位置都判断一下就好

    代码

    #include<bits/stdc++.h>
    using namespace std;
    
    int x1,y1,x2,y2;
    int x3,y3,x4,y4;
    int w,h;
    int main()
    {
        freopen("grave.in","r",stdin);
        freopen("grave.out","w",stdout);
        cin>>x1>>y1>>x2>>y2;
        cin>>x3>>y3>>x4>>y4;
        cin>>w>>h;
        int l = x2 - x1;
        int H = y2 - y1;
        if(l>=w&&y3-y1>=h)
            return puts("Yes");
        if(l>=w&&y2-y4>=h)
            return puts("Yes");
        if(H>=h&&x3-x1>=w)
            return puts("Yes");
        if(H>=h&&x2-x4>=w)
            return puts("Yes");
        return puts("No");
    }
  • 相关阅读:
    hdu 1875 畅通project再续(kruskal算法计算最小生成树)
    Http post提交和get提交
    我的软考之路(五)——数据结构与算法(3)之图
    WPF 布局控件 之 DockPanel
    oracle存储结构
    马化腾最想做的事情是人工智能
    Android_Zip解压缩工具
    Unity的 Stats 窗体, Batched、SetPass、Draw Call 等
    尝试 “实验楼”在线教育平台
    POJ 3181 Dollar Dayz 01全然背包问题
  • 原文地址:https://www.cnblogs.com/qscqesze/p/5140166.html
Copyright © 2011-2022 走看看