Wally World
Time limit1sMemory limit128 MB
Two points in a plane must meet while a single axis-parallel wall segment blocks the straight path; compute the minimum meeting time.
- Level
Medium4 of 10
- Topics
- Geometry, Math, Shortest path, Implementation
- Solved
- No attempts yet
Problem
Two star-crossed lovers want to meet. The two lovers stand at distinct points in the plane. They can travel freely except that there is a single wall which cannot be crossed. The wall is a line segment parallel to either the or the axis. Each lover can move 1 unit in 1 second. How long will it take them to be together if they both choose the best path?
Input
Each test case consists of two lines, each containing four integers. On the first line, the first two integers give the and coordinates of the first lover, and the next two give the and coordinates of the second lover. The four integers on the second line give the start and end points of the wall.
In all cases both lovers lie off the (infinite) line containing the wall — that is, the wall extended in both directions. All coordinates are positive and at most , and neither lover starts on the wall. The input is terminated by a line containing four zeroes.
Output
For each test case, output the minimum time in seconds for the two lovers to meet. Print the answer to exactly 3 decimal places, with each line in the format:
Case n: t
where is the 1-based test-case number and is the minimum time.