#T287. 最短路径问题

最短路径问题

Description

There are n points (n ≤ 100) on a plane, with the coordinates of each point ranging between -10000 and 10000.
Some of these points are connected by lines. If there is a line between two points, it means one can travel from one point to the other, i.e., there is a path between them, and the distance of the path is the straight-line distance between the two points.
The task is to find the shortest path from one point to another.

Input Format

A total of n + m + 3 lines, where:

  • The first line is an integer n.
  • Lines 2 to n + 1 (n lines in total), each contains two integers x and y, describing the coordinates of a point.
  • Line n + 2 is an integer m, representing the number of connections in the graph.
  • The subsequent m lines each describe a connection, consisting of two integers i and j, indicating that there is a line between the i-th point and the j-th point.
  • The last line contains two integers s and t, representing the source point and the target point, respectively.

Output Format

A single line with a real number (rounded to two decimal places), representing the length of the shortest path from s to t.

5 
0 0

2 0
2 2
0 2
3 1
5 
1 2
1 3
1 4
2 5
3 5
1 5

3.41