1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
#define debug(x) cout << #x << " is " << x << endl
#define inc(i, a, b) for (int i = a; i <= b; ++i)
typedef long long ll;
const int INF = 0x3f3f3f3f;
struct window {
int ax, ay, bx, by;
int id;
window() {}
window(int ax, int ay, int bx, int by, int id) : ax(ax), ay(ay), bx(bx), by(by), id(id) {}
};
int n, m;
vector<window> windows;
void click(int x, int y) {
/*for (vector<window>::reverse_iterator it = windows.rbegin(); it != windows.rend(); ++it) {
if (x >= it->ax && x <= it->bx)
if (y >= it->ay && y <= it->by) {
printf("%d\n", it->id);
windows.push_back(*it);
windows.erase((++it).base());
return;
}
}*/
for (int i = windows.size() - 1; i >= 0; --i) {
if (x >= windows[i].ax && x <= windows[i].bx)
if (y >= windows[i].ay && y <= windows[i].by) {
printf("%d\n", windows[i].id);
windows.push_back(windows[i]);
windows.erase(windows.begin() + i);
return;
}
}
puts("IGNORED");
}
int main()
{
int ax, ay, bx, by;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%d%d%d%d", &ax, &ay, &bx, &by);
windows.push_back(window(ax, ay, bx, by, i));
}
int x, y;
while (m--) {
scanf("%d%d", &x, &y);
click(x, y);
}
return 0;
}
|