暴力模拟
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 11;
int n, m;
//5号位置代表编号,6号位置代表位置
//6号位置越大代表越在上层
int windows[N][7];
int max_pos;
void click(int a, int b)
{
//第一步是找到最上面的那个点击到的窗口
//第二步是改变窗口的顺序
int pos = 0;
//list代表编号
int list = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= 4; j++)
{
//代表这个窗口在点击范围之内
if (a >= windows[i][1] && a <= windows[i][3] && b >= windows[i][2] && b <= windows[i][4])
{
if (windows[i][6] > pos)
{
pos = windows[i][6];
list = windows[i][5];
}
}
}
}
if (list != 0)
printf("%d\n", list);
else
printf("IGNORED\n");
max_pos++;
windows[list][6] = max_pos;
}
int main()
{
cin >> n >> m;
max_pos = n;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= 4; j++)
{
cin >> windows[i][j];
}
windows[i][5] = i;
windows[i][6] = i;
}
for (int i = 1; i <= m; i++)
{
int a = 0, b = 0;
cin >> a >> b;
click(a, b);
}
return 0;
}