#P1003. [NOIP 2011 提高组] 铺地毯
[NOIP 2011 提高组] 铺地毯
Description
To prepare a unique awards ceremony, the organizers lay several rectangular carpets on a rectangular area of the venue (regarded as the first quadrant of the plane Cartesian coordinate system). There are carpets, numbered from to . These carpets are laid, in increasing order of their indices, axis-parallel; a later carpet is placed on top of those already laid.
After all carpets have been laid, the organizers want to know the index of the topmost carpet that covers a given point on the floor. Note: points on the boundary and at the four vertices of a rectangular carpet are also considered covered.
Input Format
The input contains lines.
The first line contains an integer , indicating that there are carpets in total.
Each of the next lines, the -th line, describes carpet with four integers , separated by single spaces, representing the coordinates of the lower-left corner and the lengths of the carpet in the - and -directions, respectively.
The -th line contains two integers and , representing the coordinates of the query point.
Output Format
Output a single line containing one integer, the index of the required carpet; if the point is not covered by any carpet, output -1.
3
1 0 2 3
0 2 3 3
2 1 3 3
2 2
3
3
1 0 2 3
0 2 3 3
2 1 3 3
4 5
-1
Hint
[Sample Explanation 1]
As shown in the figure, carpet is drawn with solid lines, carpet with dashed lines, and carpet with double solid lines. The topmost carpet covering the point is carpet .

[Data Range]
- For of the data, .
- For of the data, .
- For of the data, , .
NOIP 2011 Senior Day 1 Problem .
Translated by ChatGPT 5
京公网安备 11011102002149号