题意
传送门 NC 16593
题解
从最大编号地毯向下枚举, O ( n ) O(n) O(n) 判断覆盖 ( x , y ) (x,y) (x,y) 的最上方点编号。
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
using namespace std;
#define maxn 10005
struct rect
{
int x1, y1, x2, y2;
rect() {}
rect(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
bool inside(int x, int y)
{
return x >= x1 && x <= x2 && y >= y1 && y <= y2;
}
};
rect rs[maxn];
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
int a, b, g, k;
scanf("%d%d%d%d", &a, &b, &g, &k);
rs[i] = rect(a, b, a + g, b + k);
}
int x, y, res = -1;
scanf("%d%d", &x, &y);
for (int i = n - 1; i >= 0; i--)
{
if (rs[i].inside(x, y))
{
res = i + 1;
break;
}
}
printf("%d\n", res);
return 0;
}