201403-2-窗口-CCF

 解题思路:模拟,窗口和点分开,此外注意顺序,。。。没读懂题,认真,要是考试的话,这种读题方式肯定要凉。

#include<iostream>
#include<cstdio>
using namespace std;
const int N=11;
struct win
{
	int x1,y1,x2,y2;
	int num;
}w[N];
struct point
{
	int x,y;
}p[N];
int main(){
	int n,m;
	cin>>n>>m;
	for (int i = 0; i <n; ++i)
	{
		cin>>w[i].x1>>w[i].y1>>w[i].x2>>w[i].y2;
		w[i].num=i+1;
	}
	for (int i = 0; i < m; ++i)
	{
		cin>>p[i].x>>p[i].y;
	}

	for (int i = 0; i < m; ++i)
	{	win temp;
		int j;
		int t=0;
		for (j = n-1; j >=0; j--)
		{
			if(p[i].x>=w[j].x1&&p[i].x<=w[j].x2&&p[i].y>=w[j].y1&&p[i].y<=w[j].y2){
				t=w[j].num;
				temp=w[j];
				for(int k=j;k<n;k++){
					w[k]=w[k+1];
				}
				w[n-1]=temp;
				break;
			}
		}
		if(j==-1){
			cout<<"IGNORED"<<endl;
		}
		else {
			cout<<t<<endl;
		}
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/lianghudream/article/details/84331392
今日推荐