• 洛谷—— P1003 铺地毯


    https://www.luogu.org/problem/show?pid=1003

    题目描述

    为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯。一共有 n 张地毯,编号从 1 到n 。现在将这些地毯按照编号从小到大的顺序平行于坐标轴先后铺设,后铺的地毯覆盖在前面已经铺好的地毯之上。

    地毯铺设完成后,组织者想知道覆盖地面某个点的最上面的那张地毯的编号。注意:在矩形地毯边界和四个顶点上的点也算被地毯覆盖。

    输入输出格式

    输入格式:

    输入文件名为carpet.in 。

    输入共n+2 行。

    第一行,一个整数n ,表示总共有 n 张地毯。

    接下来的n 行中,第 i+1 行表示编号i 的地毯的信息,包含四个正整数 a ,b ,g ,k ,每两个整数之间用一个空格隔开,分别表示铺设地毯的左下角的坐标(a ,b )以及地毯在x轴和y 轴方向的长度。

    第n+2 行包含两个正整数 x 和y,表示所求的地面的点的坐标(x ,y)。

    输出格式:

    输出文件名为carpet.out 。

    输出共1 行,一个整数,表示所求的地毯的编号;若此处没有被地毯覆盖则输出-1 。

    输入输出样例

    输入样例#1:
    3
    1 0 2 3
    0 2 3 3
    2 1 3 3
    2 2
    
    输出样例#1:
    3
    
    
    输入样例#2:
    3
    1 0 2 3
    0 2 3 3
    2 1 3 3
    4 5
    输出样例#2:
    -1

    说明

    【样例解释1】

    如下图,1 号地毯用实线表示,2 号地毯用虚线表示,3 号用双实线表示,覆盖点(2,2)的最上面一张地毯是 3 号地毯。

    【数据范围】

    对于30% 的数据,有 n ≤2 ;

    对于50% 的数据,0 ≤a, b, g, k≤100;

    对于100%的数据,有 0 ≤n ≤10,000 ,0≤a, b, g, k ≤100,000。

    noip2011提高组day1第1题

    每天沉迷于水题~

     1 #include <cstdio>
     2 
     3 using namespace std;
     4 
     5 const int N(10000+15);
     6 int n,x,y,a[N],b[N],xl[N],yl[N],ans=-1;
     7 
     8 int main()
     9 {
    10     scanf("%d",&n);
    11     for(int i=1;i<=n;i++)
    12         scanf("%d%d%d%d",&a[i],&b[i],&xl[i],&yl[i]);
    13     scanf("%d%d",&x,&y);
    14     for(int i=1;i<=n;i++)
    15         if(x>=a[i]&&y>=b[i]&&x-a[i]<=xl[i]&&y-b[i]<=yl[i]) ans=i;
    16     printf("%d",ans);
    17     return 0;
    18 }
    ——每当你想要放弃的时候,就想想是为了什么才一路坚持到现在。
  • 相关阅读:
    Spring IOC 容器源码分析
    OAuth协议简介
    MySQL安装步骤
    C# read and compute the code lines number of cs files based on given directory
    C# StreamWriter log batch message sync and async
    HttpClient SendAsync
    WebRequest, WebRequest.Create GetResponse() GetResponseStream()
    C# FileSystemWatcher
    Access Volumn via extern and invoke win 32 dll
    Change file readonly property File.SetAttribute and new FileInfo readonly property
  • 原文地址:https://www.cnblogs.com/Shy-key/p/6942167.html
Copyright © 2020-2023  润新知