You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.0 KiB
85 lines
2.0 KiB
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
//是不是在范围内
|
|
bool isInside(int x1, int y1, int x2, int y2, int x, int y) {
|
|
if (x >= x1 && x <= x2 && y >= y1 && y <= y2) return true;
|
|
return false;
|
|
}
|
|
|
|
//层的结构体
|
|
struct layer {
|
|
int x1, y1, x2, y2, index, sortId;
|
|
};
|
|
|
|
//排序函数
|
|
int cmp(layer s1, layer s2) {
|
|
return s1.sortId > s2.sortId;
|
|
}
|
|
|
|
//重置索引号
|
|
void resetSortId(vector<layer> &vec1) {
|
|
for (int i = 0; i < vec1.size(); i++) {
|
|
vec1[i].sortId = vec1.size() - i;
|
|
}
|
|
}
|
|
|
|
int main() {
|
|
int n, m;
|
|
cin >> n >> m;
|
|
vector<layer> vec1;
|
|
//读入到结构体
|
|
for (int i = 0; i < n; i++) {
|
|
layer mylayer;
|
|
cin >> mylayer.x1 >> mylayer.y1 >> mylayer.x2 >> mylayer.y2;
|
|
//层
|
|
mylayer.index = i + 1;
|
|
//排序号
|
|
mylayer.sortId = i + 1;
|
|
vec1.push_back(mylayer);
|
|
}
|
|
//初始化数据加入,是有序的,无需进行排序
|
|
sort(vec1.begin(), vec1.end(), cmp);
|
|
//重置索引
|
|
resetSortId(vec1);
|
|
|
|
//结果
|
|
vector<int> result;
|
|
|
|
//模拟点击
|
|
int x, y;
|
|
for (int i = 0; i < m; i++) {
|
|
cin >> x >> y;
|
|
|
|
bool found = false;
|
|
for (int j = 0; j < vec1.size(); j++) {
|
|
if (isInside(vec1[j].x1, vec1[j].y1, vec1[j].x2, vec1[j].y2, x, y)) {
|
|
result.push_back(vec1[j].index);
|
|
found = true;
|
|
vec1[j].sortId = INT32_MAX;
|
|
break;
|
|
}
|
|
}
|
|
if (found) {
|
|
//初始化数据加入,是有序的,无需进行排序
|
|
sort(vec1.begin(), vec1.end(), cmp);
|
|
//重置索引
|
|
resetSortId(vec1);
|
|
} else {
|
|
result.push_back(-1);
|
|
}
|
|
}
|
|
|
|
//输出
|
|
for (int i = 0; i < result.size(); i++) {
|
|
if (result[i] >= 0) {
|
|
cout << result[i] << endl;
|
|
} else {
|
|
cout << "IGNORED" << endl;
|
|
}
|
|
}
|
|
system("pause");
|
|
return 0;
|
|
}
|