洛谷_P1003 [NOIP2011 提高组] 铺地毯_暴力枚举

洛谷_P1003 [NOIP2011 提高组] 铺地毯_暴力枚举

 

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

const int N=11111;
struct rug{ int a,b,aa,bb; }in[N];
int x,y;

bool f( const struct rug &z )
{			// 底点+边长 
    return ( x>=z.a && x<=z.a+z.aa && y>=z.b && y<=z.b+z.bb );
}			// 在矩形地毯边界和四个顶点上的点也算被地毯覆盖

int main()
{
    int n,i;
    while( cin>>n )
    {
        memset( in,0,sizeof( in ) );
        for( i=1;i<=n;i++ )
        {
            cin>>in[i].a>>in[i].b>>in[i].aa>>in[i].bb;
        }
        cin>>x>>y;

        for( i=n;i;i-- )					// 逆序遍历 
            if( f( in[i] ) ) break;
            
        if( i )     cout<<i<<endl;
        else        cout<<"-1"<<endl;		// 特判 
    }
    return 0;
}
// 没看懂就先找一找有没有样例解释

猜你喜欢

转载自blog.csdn.net/qq_63173957/article/details/125475848