码迷,mamicode.com
首页 > 其他好文 > 详细

luoguP1003 铺地毯 题解(NOIP2011)

时间:2018-04-05 11:52:16      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:using   ble   target   ++   span   str   lan   names   tar   

luoguP1003 铺地毯  题目

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
inline int read()
{
    int sum=0,p=1;char ch=getchar();
    while(!((0<=ch && ch<=9) || ch==-))ch=getchar();
    if(ch==-)p=-1,ch=getchar();
    while(0<=ch && ch<=9)sum=sum*10+ch-48,ch=getchar();
    return sum*p;
}
struct ditan{
    int zxx,zxy,ysx,ysy;
}a[10001];
int main()
{
    int n,xx,yy,lx,ly,x,y;
    n=read();
    for(int i=1;i<=n;i++)
    {
        xx=read();yy=read();lx=read();ly=read();
        a[i].zxx=xx;a[i].zxy=yy;a[i].ysx=xx+lx;a[i].ysy=yy+ly;
    }
    x=read();y=read();
    for(int i=n;i>=1;i--)
    {
        if(a[i].zxx<=x&&a[i].zxy<=y&&a[i].ysx>=x&&a[i].ysy>=y)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;
    return 0;
}

 



luoguP1003 铺地毯 题解(NOIP2011)

标签:using   ble   target   ++   span   str   lan   names   tar   

原文地址:https://www.cnblogs.com/cjoierljl/p/8721082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!