Codeforces 1028C - Rectangles
You are given n rectangles on a plane with coordinates of their bottom left and upper right points. Some (n−1) of the given n rectangles have some common point. A point belongs to a rectangle if this point is strictly inside the rectangle or belongs to its boundary.
Find any point with integer coordinates that belongs to at least (n−1) given rectangles.
Input:
The first line contains a single integer n (2≤n≤132674) — the number of given rectangles.
Each the next n lines contains four integers x1, y1, x2 and y2 (−109≤x1<x2≤109, −109≤y1<y2≤109) — the coordinates of the bottom left and upper right corners of a rectangle.
Output:
Print two integers x and y — the coordinates of any point that belongs to at least (n−1) given rectangles.
範例:
input:
1 | 3 |
output:
1 | 1 1 |
input:
1 | 3 |
output:
1 | 1 1 |
input:
1 | 4 |
output:
1 | 1 1 |
input:
1 | 5 |
output:
1 | 3 4 |
Note:
The picture below shows the rectangles in the first and second samples. The possible answers are highlighted.
The picture below shows the rectangles in the third and fourth samples.
題意:
提供n個矩形,其坐標分別為左下角和右上角。 給定的n個矩形中的某些(n-1)個具有一些公共點。 如果某點嚴格位於矩形內或屬於其邊界,則該點屬於矩形。
找具有至少屬於(n-1)個給定矩形的整數坐標的任何點。
思路:
要在N−1個矩形中,因此只要一個一個刪去後,判斷剩下的N−1 個矩形有沒有套在一起就可以了。