Dzidzio and sheep
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
...
— All my life I dreamed of becoming a great artist. To have a cool car, a solid suit, and most importantly — for Mom to be proud of me!
Dzidzio
It so happened that our hero’s Mom loves the combination of yellow and blue colors. Mom has a very large field in the village — a coordinate plane. Besides this, Mom has \(n+m\) herds of sheep. For reasons unknown to us, \(n\) herds are blue, and \(m\) are yellow. For each herd, there is a specific rectangle (parallel to the coordinate axes) where this herd likes to graze.
Dzidzio noticed: if both yellow and blue sheep graze at some point, they will form a beautiful combination of yellow and blue. Dzidzio wants to choose one blue herd and one yellow herd such that the total area where both yellow and blue sheep will be is as large as possible. However, this task turned out to be beyond his power. In addition, Dzidzio had problems at customs, so he asks you for help.
Input
The first line contains two integers \(n\) and \(m\), separated by a single space — the number of blue and yellow herds, respectively.
The next \(n\) lines describe the favorite pastures of the blue sheep.
Each line contains 4 integers \(x_1\), \(y_1\), \(x_2\), and \(y_2\) — the coordinates of the bottom-left and top-right points of the rectangle, respectively.
Then follows \(m\) lines describing the favorite pastures of the yellow sheep in a similar format.
Output
In a single line, print two integers separated by a space — the 1-based index of the blue herd and the 1-based index of the yellow herd, such that the area where the yellow and blue colors are combined is as large as possible.
If there are several optimal answers, you may output any of them.
Constraints
50% of tests: \(1 \le n, m \le 10\) and \(0 \le |x_1|,|x_2|,|y_1|,|y_2| \le 10^3\),
50% of tests: \(10 < max(n, m) \le 100\) and \(10^3 < |x_1|,|x_2|,|y_1|,|y_2| \le 10^9\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 2 2 0 0 4 4 4 4 7 7 2 2 5 5 0 0 4 2 | 1 2 |
| Input (stdin) | Output (stdout) |
|---|---|
| 1 1 0 0 5 5 5 5 10 10 | 1 1 |
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|