[ACM]NOIP2011D1T1复现-铺地毯

逆向考虑即可解决

#include<iostream>

using namespace std;

const int maxn= 100000 +5;

int a[maxn][4];//0-x,1-y,2-x-length,3-y-length

int main(){
	int n,flag=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2]>>a[i][3];
	}
	int x,y;
	cin>>x>>y;
	for(int i=n;i>0;i--)
	{
		if((a[i][0] + a[i][2] >= x) && (a[i][1] + a[i][3] >= y) && (a[i][0] <= x) && (a[i][1] <=y))
		{
			flag=i;
			break;
		}
		else if(a[i][0]==x && a[i][1]==y)
		{
			flag=i;
			break;
		}
	}
	if(flag!=0)	cout<<flag;
	else	cout<<-1;
	return 0;
} 
posted @ 2020-11-10 19:04  Do1phln  阅读(70)  评论(0编辑  收藏  举报