文章目录
- C++
- 总结
本题链接:窗口
本博客给出本题截图:
C++
#include <iostream> using namespace std; const int N = 15; int n, m; struct { int x1, y1, x2, y2; int id; }w[N]; int get(int x, int y) { for (int i = n; i; i -- ) { auto k = w[i]; if (x >= k.x1 && x <= k.x2 && y >= k.y1 && y <= k.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 { auto k = w[t]; cout << k.id << endl; for (int i = t; i < n; i ++ ) w[i] = w[i + 1]; w[n] = k; } } return 0; }
总结
小模拟题