F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Go to Class

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 335    Accepted Submission(s): 29


Problem Description
Sophia is a student. Every day she goes to class from her dormitory to the classroom. Sophia likes sleeping and she always gets up late, so she wants to know what the shortest path is.

The campus of the university is divided into several blocks. The picture below shows the campus. Each block is a lawn and you are not allowed to cross them. Sophia starts from her dormitory to classroom. The dormitory and classroom are 2 points in the map. Please look at the following graph for further clarifications.

 

Input
The input consists of several test cases. Each case begins with two numbers n , m (0 < n, m<=25) , the number of horizontal roads and vertical roads, respectively. Then one line consists of 4 integer numbers x0, y0, x1, y1 , means the dormitory's location is (x0, y0) and the classroom's location is (x1, y1) . Then two lines follow. The first line consists of 2n integer numbers, the y coordinates of each horizontal road's lower side and upper side from south to north. The second line consists of 2m integer numbers, the x coordinates of each vertical road's left side and right side from west to east. The campus always has at least one vertical road and at least one horizontal road. The classroom and dormitory will always in the campus and won't appear inside any lawn. All coordinates will be in the range (-100000, 100000), and the width of each road is greater than 0. N = 0 , M = 0 indicates the end of input file.
 

Output
For each test case, you should print only one line consists of the length of the shortest path you found in the format as indicated in the sample output (with accuracy 10^-4 ).
 

Sample Input
2 2 -3 -3 3 3 -5 -3 3 5 -5 -3 3 5 0 0
 

Sample Output
Case 1: 12.0000
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 18:04:09, Gzip enabled