| <p> |
| Mr. Fox is going on a trip to Scotland to witness its many beautiful lochs! He's heard that skimboarding |
| is a fun pastime, somewhat similar to surfing, and he'd like to give it a try while he's there. |
| </p> |
|
|
| <p> |
| He soon finds himself on a flat beach by the side of a loch. The beach can be represented by an infinite 2D plane, |
| with <strong>N</strong> axis-aligned rectangular pools of shallow water on it. |
| The <strong>i</strong>th pool has a pair of opposite corners at coordinates |
| (<strong>x<sub>1</sub></strong>, <strong>y<sub>1</sub></strong>) and |
| (<strong>x<sub>2</sub></strong>, <strong>y<sub>2</sub></strong>). |
| All of the pools can arbitrarily overlap with one another, the result being that there's shallow water everywhere within |
| the union of the pools' rectangles (including right on its edges), and no water anywhere else |
| (Mr. Fox isn't brave enough to venture into the loch itself yet!). |
| </p> |
|
|
| <p> |
| Mr. Fox would like to get a running start and then launch himself across the water at some location, skimboarding across |
| the pools in a straight line until he hits a point with no water. In other words, his skimboarding debut will consist of a |
| line segment contained within the union of the pools' rectangles (inclusive of borders). |
| What's the maximum length this line segment can have? |
| </p> |
|
|
|
|
| <h3>Input</h3> |
| <p> |
| Input begins with an integer <strong>T</strong>, the number of places Mr. Fox goes skimboarding. |
| For each place, there is first a line containing the integer <strong>N</strong>. |
| Then <strong>N</strong> lines follow, the <strong>i</strong>th of which contains the space-separated integers |
| <strong>x<sub>1</sub></strong>, <strong>y<sub>1</sub></strong>, |
| <strong>x<sub>2</sub></strong>, and <strong>y<sub>2</sub></strong>. |
| </p> |
|
|
| <h3>Output</h3> |
| <p> |
| For the <strong>i</strong>th place, print a line containing "Case #<strong>i</strong>: " followed by |
| the length of longest possible skimboarding path rounded to 6 decimal places. |
| </p> |
|
|
| <p> |
| Absolute errors of up to 2e-6 will be ignored. |
| </p> |
|
|
|
|
| <h3>Constraints</h3> |
| <p> |
| 1 ≤ <strong>T</strong> ≤ 20 <br /> |
| 1 ≤ <strong>N</strong> ≤ 20 <br /> |
| -1,000,000 ≤ <strong>x<sub>1</sub></strong> < <strong>x<sub>2</sub></strong> ≤ 1,000,000 <br /> |
| -1,000,000 ≤ <strong>y<sub>1</sub></strong> < <strong>y<sub>2</sub></strong> ≤ 1,000,000 <br /> |
| </p> |
|
|
| <h3>Explanation of Sample</h3> |
| <p> |
| In the first case, (2, 0) to (5, 5) is an optimal path. |
| </p> |
|
|
|
|