ÀÂÒ
Language:

Remote Training on Programming

Problems On-line status Contests FAQ
For authors:
Register  ||  Login
 
Hello, Guest! Login or register.

894. Rectangles.

Time Limit: 3 seconds
Memory Limit:32768KB
Points:10
View Problem Statistics Submit Problem added Administrator

Let there be N nondegenerate rectangles with sides parallel to coordinate axes. It is known that the borders of these rectangles do not intersect and there are no identical borders.

Let us say that rectangle A is nested inside rectangle B if any point belonging to A also belongs to B, and AB.

Let us say that rectangle A is immediately nested inside rectangle B if A is nested inside B and A is not nested inside any other rectangle that is nested inside B.

Write a program to analyse immediate nesting of rectangles.

Limitations

<= N <= 100 000; 0 <= xij, yij < 231 – coordinates of the opposite vertices of a rectangle.

Input

The first line of the input file specifies an integer N. Then N lines follow. Of these lines, line number i specifies 4 integers: xi1, yi1, xi2, yi2—the coordinates of the opposite vertices of the i-th rectangle.

Output

Write N lines to the output file. Line number i must contain the number of a rectangle inside which rectangle number i is immediately nested, or 0 if there is no such rectangle in the input set.

Sample

Standard input

Standard output

5

0 0 10 10

1 2 4 5

2 3 3 4

7 7 8 8

0 11 1 12

0

1

2

1

0

 


View Problem Statistics Submit Author/source:
Sorted Problems / Mathematics / Geometry /
16. Polygon 894. 7. Reflections 892. Solar eclipse 872. Triangle
Problems from Contests / ACM Contests / Rybinsk-2010 /
893. H - Green wave 894. 895. J - Inside the OS
We can all benefit by doing occasional "toy" programs, when artificial restrictions are set up, so that we are forced to push our abilities to the limit. The art of tackling miniproblems with all our energy will sharpen our talents for the real problems. Donald E. Knuth.
time generating 0.64 sec.
© Copyright VSTU, AVT, Nosov D.A.