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

Help the People Been Trapped

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 213    Accepted Submission(s): 34


Problem Description
Full Score of Fear, the Movie 12 of Detective Conan has been published recently.


Before going to the concert, Conan had been attacked and was unconscious. But Ran wasn¡¯t aware of Conan¡¯s disappearance. Then they went into the odeum, and the concert started.
Suddenly, the bombs in the odeum blasted and the whole building was on fire. All the audiences are trapped in the odeum, include Mouri Ran and Haibara Ai. Thousands of people are in danger now.

After the explosion, some walls have collapsed and blocked the way. Now Conan gets a map from the police, and he knows the location of all the hindrances. Also, he knows that Ran is a karate superior, and she can destroy some hindrances. (Horrific) As destroying the hindrance is a hard job, Conan wants to find a way to get out of the odeum crossing the least number of hindrances.

But the odeum is so large that it¡¯s not an easy work to find that way. Can you help Conan and the people trapped in the odeum?
 

Input
The input consists of several test cases. The first line of the input is the number of the cases. There are no more than 20 cases.
Each case contains an integer M on its first line, which is the number of the hindrances. 0<=M<=4000.
The next m lines describe m hindrances each. Each line contains four integers in each, x1, y1, x2, y2, means that there is a hindrance from (x1, y1) to (x2, y2). The hindrances will not cross each other, but they can meet at the end point.
The last line contains two integers, x, y, means that the people are trapped at point (x, y). You can assume that this point will not be on any of the hindrances.
Every coordinate is between -10,000 and 10,000.
 

Output
For each case, print the least number of hindrances need to be destroyed. (If you need to cross an end point, it should be counted multiple times; look at the second sample for more details) Use the format in the sample.
 

Sample Input
3 0 0 0 12 0 0 2 0 2 0 4 0 0 2 2 2 2 2 4 2 0 4 2 4 2 4 4 4 0 0 0 2 0 2 0 4 2 0 2 2 2 2 2 4 4 0 4 2 4 2 4 4 1 1 6 0 2 1 0 0 2 -1 0 1 0 -1 0 0 2 -2 -1 0 2 2 -1 -2 -1 2 -1 0 1
 

Sample Output
Case 1: Need to destroy 0 hindrances. Case 2: Need to destroy 1 hindrances. Case 3: Need to destroy 2 hindrances.
 

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-05-06 02:54:25, Gzip enabled