P1003 铺地毯

P1003 铺地毯

题目链接:https://www.luogu.org/problem/P1003

代码:

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

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int n,i,t=-1,x,y;
    int a[100005],b[100005],c[100005],d[100005];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
    }
    scanf("%d %d",&x,&y);
    for(i=0;i<n;i++){
        if(x>=a[i]&&x<=a[i]+c[i]&&y>=b[i]&&y<=b[i]+d[i]){//将x,y从第一张地毯开始搜索,如果在范围内就记下地毯的编号,后面的编号覆盖前面的编号;
            t = i+1;
        }
    }
    printf("%d\n",t);
    return 0;
}
posted @ 2019-08-01 20:20  幽灵小一只  阅读(106)  评论(0编辑  收藏  举报