Mock CCC '19 Contest 2 S2 - Tudor Puts A Goat On A Rope

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type

Tudor is going on vacation!

While Tudor is on vacation, he decides to take his goat and tie to a fence post with a rope. Because he doesn't want to infringe too much on the goat's freedom to trample on the earth, he wants the rope to be as long as possible. However, because he doesn't feel like dealing with property damage, he doesn't want the goat to be able to run into his house.

Tudor's house is modeled as an axis-aligned rectangle with corners at (x_1, y_1) and (x_2, y_2), and the fence post is at (x, y).

Compute the length of the longest rope such that the goat cannot reach Tudor's house.


-10^3 \le x, y, x_1, y_1, x_2, y_2 \le 10^3

(x, y) will not fall inside the axis-aligned rectangle with corners at (x_1, y_1) and (x_2, y_2).

x_1 < x_2

y_1 < y_2

There are no explicit subtasks for this problem. There will be 15 secret test cases, each worth one mark.

Input Specification

The input will consist of six space-separated integers, x, y, x_1, y_1, x_2, y_2.

Output Specification

Output, on a single line, the maximum length of rope Tudor can use. This number must be rounded to three decimal places.

Sample Input 1

7 4 0 0 5 4

Sample Output 1


Sample Input 2

6 0 0 2 7 6

Sample Output 2


Sample Input 3

4 8 7 8 9 9

Sample Output 3



There are no comments at the moment.