#P7181. [BalticOI 2004] Rectangles (Day2)
[BalticOI 2004] Rectangles (Day2)
Description
There are rectangles on a plane. Their sides are parallel to the coordinate axes. These rectangles may overlap, coincide, or be separated. For each vertex coordinate , both and are non-negative integers. The -coordinate does not exceed , and the -coordinate does not exceed .
Point is at . Let , , and . Then point lies on segment or .
Segment may intersect rectangles (even if it intersects only a rectangle vertex, it is still considered an intersection).
You need to find a point such that the number of rectangles intersected by segment is as large as possible.
Input Format
The first line contains three integers .
The next lines each contain four integers, representing the lower-left corner coordinates and the upper-right corner coordinates of the -th rectangle.
Output Format
Output one line with three integers, in order:
- the maximum number of intersected rectangles;
- the coordinates of point in this case.
If there are multiple solutions, output any one of them.
22 14 8
1 8 7 11
18 10 20 12
17 1 19 7
12 2 16 3
16 7 19 9
8 4 12 11
7 4 9 6
10 5 11 6
5 22 12
Hint
Sample 1 Explanation

The output can also be 5 22 11.
Constraints
For of the testdata, , .
Notes
Translated from BalticOI 2004 Day2 B Rectangles.
Special Thanks
Thanks to
Translated by ChatGPT 5
京公网安备 11011102002149号