思路:窗口下层到上层排序,输入从上层找,找到后此层与上层换位置
#include<bits/stdc++.h>
using namespace std;
#define _for(i,a,b) for(int i=a;i<b;i++)
const int n=1010;
typedef struct Window
{
int x1,y1;
int x2,y2;
int num;
}window;
void swap(window &a,window &b)
{
window c;
c.x1=a.x1;
c.x2=a.x2;
c.y1=a.y1;
c.y2=a.y2;
c.num=a.num;
a.x1=b.x1;
a.x2=b.x2;
a.y1=b.y1;
a.y2=b.y2;
a.num=b.num;
b.x1=c.x1;
b.x2=c.x2;
b.y1=c.y1;
b.y2=c.y2;
b.num=c.num;
}
int main()
{
int N,M;
cin>>N>>M;
vector<window> w(N);
_for(i,0,N)
{
cin>>w[i].x1>>w[i].y1>>w[i].x2>>w[i].y2;
w[i].num=i+1;
}
while(M--)
{
int x,y;
cin>>x>>y;
for(int i=N-1;i>=0;i--)
{
if(x>=w[i].x1 && w[i].x2>=x && y>=w[i].y1 && w[i].y2>=y)
{
cout<<w[i].num<<endl;
if(i!=N-1)
{
swap(w[i],w[N-1]);
}
break;
}
else if( i==0)
{
cout<<"IGNORED"<<endl;
break;
}
}
}
return 0;
}
|