问题描述
给出n个地毯的左下角坐标及长宽,给出一点,问此点最上面覆盖的地毯编号。(若没有任何地毯覆盖输出-1)
样例输入
3
1 0 2 3
0 2 3 3
2 1 3 3
2 2
样例输出
3
算法讨论
暴力模拟,将所有数据存起来,从尾到扫描,若点在地毯范围内就输出,终止。最后没有符合条件的就输出-1。时间复杂度O(n)。
const
maxn=10000;
var
a:array[1..maxn,1..4] of longint;
i,n,x,y:longint;
begin
read(n);
for i:=1 to n do
read(a[i,