题目描述:
思路:
数据量仅为10,所以我们可以简单模拟,用数组实现移动过程,然后逐个去对比查找即可
相对简单,直接附代码
代码:
#include<bits/stdc++.h>
using namespace std;
const int N = 15;
int n, m;
struct W
{
int x1, y1, x2, y2;
int id;
}w[N];
int get(int x, int y)
{
for (int i = n; i>0; i -- )
if (x >= w[i].x1 && x <= w[i].x2 && y >= w[i].y1 && y <= w[i].y2)
return i;
return 0;
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i ++ )
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
w[i] = {x1, y1, x2, y2, i};
}
while (m -- )
{
int x, y;
cin >> x >> y;
int t = get(x, y);
if (!t) puts("IGNORED");
else
{
cout << w[t].id << endl;
auto r = w[t];
for (int i = t; i < n; i ++ ) w[i] = w[i + 1]; //移动位置
w[n] = r; //置于顶层
}
}
return 0;
}