1205: 铺地毯

文件提交:无需freopen 内存限制:128 MB 时间限制:1.000 S
评测方式:普通裁判 命题人:
提交:1 解决:1

题目描述

为了准备一个独特的颁奖典礼,组织者在会场的一片矩形区域(可看做是平面直角坐标系的第一象限)铺上一些矩形地毯。一共有 lns="http://www.w3.org/1998/Math/MathML"> 张地毯,编号从 lns="http://www.w3.org/1998/Math/MathML">1 到 lns="http://www.w3.org/1998/Math/MathML">。现在将这些地毯按照编号从小到大的顺序平行于坐标轴先后铺设,后铺的地毯覆盖在前面已经铺好的地毯之上。

地毯铺设完成后,组织者想知道覆盖地面某个点的最上面的那张地毯的编号。注意:在矩形地毯边界和四个顶点上的点也算被地毯覆盖。

输入

输入共 lns="http://www.w3.org/1998/Math/MathML">+2 行。

第一行,一个整数 lns="http://www.w3.org/1998/Math/MathML">,表示总共有 lns="http://www.w3.org/1998/Math/MathML"> 张地毯。

接下来的 lns="http://www.w3.org/1998/Math/MathML"> 行中,第 lns="http://www.w3.org/1998/Math/MathML">+1 行表示编号 lns="http://www.w3.org/1998/Math/MathML"> 的地毯的信息,包含四个整数 lns="http://www.w3.org/1998/Math/MathML">,,,,每两个整数之间用一个空格隔开,分别表示铺设地毯的左下角的坐标 lns="http://www.w3.org/1998/Math/MathML">(,) 以及地毯在 lns="http://www.w3.org/1998/Math/MathML"> 轴和 lns="http://www.w3.org/1998/Math/MathML"> 轴方向的长度。

第 lns="http://www.w3.org/1998/Math/MathML">+2 行包含两个整数 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML">,表示所求的地面的点的坐标 lns="http://www.w3.org/1998/Math/MathML">(,)

输出

输出共 lns="http://www.w3.org/1998/Math/MathML">1 行,一个整数,表示所求的地毯的编号;若此处没有被地毯覆盖则输出 -1

样例输入

3
1 0 2 3
0 2 3 3
2 1 3 3
2 2

样例输出

3

提示

【样例解释 1】

如下图,lns="http://www.w3.org/1998/Math/MathML">1 号地毯用实线表示,lns="http://www.w3.org/1998/Math/MathML">2 号地毯用虚线表示,lns="http://www.w3.org/1998/Math/MathML">3 号用双实线表示,覆盖点 lns="http://www.w3.org/1998/Math/MathML">(2,2) 的最上面一张地毯是 lns="http://www.w3.org/1998/Math/MathML">3 号地毯。

【数据范围】

对于 lns="http://www.w3.org/1998/Math/MathML">30% 的数据,有 lns="http://www.w3.org/1998/Math/MathML">2
对于 lns="http://www.w3.org/1998/Math/MathML">50% 的数据,lns="http://www.w3.org/1998/Math/MathML">0,,,100
对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,有 lns="http://www.w3.org/1998/Math/MathML">0104lns="http://www.w3.org/1998/Math/MathML">0,,,105

noip2011 提高组 day1 第 lns="http://www.w3.org/1998/Math/MathML">1 题。