Need help in an interesting problem

Revision en3, by 1k_GH_EZ, 2022-08-24 19:07:25

You are Given N circles on a 2D co-ordinate plane. You are initially standing on the point (X1, Y1) and wish to go to the point (X2, Y2) according to following rules:- — You travel at speed of 1 unit/sec — You incur d damage when you're beyond any of the circular regions for d time. i.e if you spend 0.55 seconds outside the circular region, you suffer from 0.55 damage — The circular regions may overlap

You need to find the minimum damage you can suffer while traveling from starting point to the final point. Answer needs to be truncated to exactly 6 decimal points.

INPUT FORMAT :- The first line contains X1, Y1, X2 and Y2 (The co-ordinates of the starting and end positions) Next line contains integer N, denoting number of circles Each of the next N lines is a 3-tuple wherein the ith line contains Xi, Yi and Ri (the X and Y co-ordinates of the center and the radius of the ith circle)

For instance:- 0 0 2 2

1

1 1 1

One optimal path is to go straight from origin to 2,2. Distance covered outside the circle would be 2 * (sqrt(2) — 1) = 0.828427

Tags geometry, greedy, graphs

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English 1k_GH_EZ 2022-08-24 19:07:25 4 Tiny change: 'n0 0 2 2\n1\n1 1 1\n\' -> 'n0 0 2 2\n\n1\n\n1 1 1\n\'
en2 English 1k_GH_EZ 2022-08-24 19:06:19 171
en1 English 1k_GH_EZ 2022-08-24 17:49:04 971 Initial revision (published)