0% found this document useful (0 votes)
55 views

Shortest Path To Work: Problem

You must find the shortest path from the starting point (Xs, Ys) to the finishing point (Xf, Yf) avoiding obstacles. The input provides the starting/finishing coordinates and up to 105 obstacle coordinates. The output should list the points in the shortest path or state "IMPOSSIBLE" if no path exists. Scoring rewards shorter paths and penalizes intersections with obstacles or inability to reach the destination.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Shortest Path To Work: Problem

You must find the shortest path from the starting point (Xs, Ys) to the finishing point (Xf, Yf) avoiding obstacles. The input provides the starting/finishing coordinates and up to 105 obstacle coordinates. The output should list the points in the shortest path or state "IMPOSSIBLE" if no path exists. Scoring rewards shorter paths and penalizes intersections with obstacles or inability to reach the destination.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Shortest path to work

Problem
You just woke up and realized you’re running late to go to work. You get in the car and start thinking the fastest and
shortest path to reach your colleagues for the scheduled meeting. You turn on the radio and you find out that there are
several obstacles along your way: a demonstration, a car accident, construction sites, traffic jams and many more.

You must find the shortest path starting from point A (home) to point B (workplace). A path is an ordered sequence of
points connected one to another with a single and straight line.

Input format
The input file is made of several lines:
 The first one contains 4 integers (Xs ; Ys; Xf ; Yf) identifying the coordinates of the starting point (Xs ; Ys) and the
finishing point (Xf ; Yf).
 The second one contains the N number of obstacles. An obstacle is a triangle which vertexes are 3 couples of
coordinates: (ax ; ay), (bx ; by), (cx ; cy). Obstacles may overlap.
 Each of the following N lines indicates the vertexes of one obstacle.

Please note that a problem can be unsolvable, i.e. it is possible that there is no path to reach the destination. The perimeter
of the obstacle is considered as part of the obstacle.

Input example:

23 0 0 12 Starting point & Finishing point


2 Number of obstacles
14 1 14 50 16 1 First obstacle coordinates
0 14 20 14 0 13 Second obstacle coordinates

Output format
The output file is made of several lines:
 The first one contains the number P of points your path is made of.
 Each of the following P lines contains the coordinates of a single point: two integers values separated with a
space.
If no path exists (or your algorithm can't find it) then the output must be one single line reporting exactly the word:
IMPOSSIBLE. Please remember that the file encoding must be ASCII (or, in this case, UTF-8 as well).

Output example:

3 Number of points
23 0 First point
14 0 Second point
0 12 Third point

Constraints
0 <= N <= 105
-106 <= x <= 106, -106 <= y <= 106 (for each coordinate)
0 <= P <= 104

Scoring
Rating is assigned as 1/(total path length) *1.000.000
Exceptions:

 If you output "IMPOSSIBLE" the score is always 0.


 If your solution intersects one of the given obstacles, or you can’t reach the finishing point your score is always
-100.

You might also like