唯独需要注意的是窗口需要切换
#include <iostream>
#include <vector>
using namespace std;
struct point{
int x;
int y;
};
vector<pair<point,point>> window;
vector<int> pos;
int main(int argc, const char * argv[]) {
int n=0,m=0;
cin>>n>>m;
for(int i=0;i<n;i++){
point p1;
point p2;
cin>>p1.x>>p1.y>>p2.x>>p2.y;
window.push_back(make_pair(p1,p2));
pos.push_back(i);
}
for(int i=0;i<m;i++){
int res=-1;
int x=0,y=0;
cin>>x>>y;
for(int j=0;j<n;j++){
if(x>=window[j].first.x&&x<=window[j].second.x&&y>=window[j].first.y&&y<=window[j].second.y)
res=j;
}
if(res!=-1){
cout<<pos[res]+1<<endl;
pair<point,point> temp=window[res];
//点击成功,交换窗口
int k=0;
int tempos=pos[res];
for(k=res;k<window.size()-1;k++){
window[k]=window[k+1];
pos[k]=pos[k+1];
}
window[k]=temp;
pos[k]=tempos;
}
else
cout<<"IGNORED"<<endl;
}
return 0;
}