Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem E ( answer in python , C# or Javascript ) Your dog Spot is let loose in the park. Well, relatively loose - he

Problem E ( answer in python , C# or Javascript)
Your dog Spot is let loose in the park. Well, relatively loose - he is tied to a post with a leash, limiting his movements. Spread around the park are various squeaky toys and other dog paraphernalia, which Spot happily goes after when he sees them. When he gets to a toy he will chew at it for a while until it has become defunct, at which point he will go after the next toy, which looks much squeakier.
This is all very well, but there are obstacles to Spot's joyful canine play: trees. In the park there are several trees, and if Spot walks around a tree his leash gets wrapped around the tree, making his movements more limited. Being a dog, with pressing squeaky matters to attend to, Spot does not really have time to take things such as trees into account, and always goes directly in a straight line for his next toy. If he can't get to his next toy because he has run out of leash, Spot will start barking uncontrollably (as no doubt any of us would) and you have to help him. How long would Spot's leash have to be in order for him to run out of toys before he runs out of leash?
For practical purposes, you may assume that (when seen from above) Spot, his toys, and the trees are points, and that the post that the leash is tied to will not hinder Spot's movements in any way. After having finished chewing a toy, Spot always goes for the most shiny unchewed toy. The post to which Spot's leash is tied is located at coordinates (0,0), and this is also where Spot is initially located.
Input
The first line of input consists of two integers n and m, where 1n50 is the number of toys in the park and 0m50 is the number of trees in the park. Then follow n lines, each containing two integers x,y giving the coordinates of a toy. The toys are listed in decreasing order of shininess. This is followed by m lines, each containing two integers x,y, indicating that there is a tree at those coordinates.
Each coordinate is bounded by 10000 in absolute value. The toys, the trees and the post are all in different positions, and Spot's route will never take him within distance 0.001 of any tree.
Output
Write a single line containing the length needed for the leash in order for Spot to be able to get to all his toys, rounded to two decimal digits.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions