#P1907. 设计道路
设计道路
Description
You are given an undirected complete graph with nodes on a 2D plane (that is, every pair of points is connected by an edge). The coordinates of node are .
There are two types of edges in the undirected graph: Rome Road and Dirt Road.
Let the set of all Rome Road edges be , and let denote the length of segment . Then the weight of an edge is:
$$c(A_i,A_j)=\begin{cases}d_R \cdot l(A_i,A_j),&(A_i,A_j) \in S\\d_D \cdot l(A_i,A_j),&(A_i,A_j) \notin S\end{cases}$$That is, the length of the edge times the corresponding coefficient ( for Rome Road, for Dirt Road).
All edges incident to nodes and are guaranteed to be Dirt Roads.
Now, you need to find the shortest path between nodes and .
Input Format
- The first line contains two decimals .
- The second line contains a positive integer .
- The next lines: on the -th line, two decimals .
- Then several lines (terminated by
0 0), each containing two positive integers , indicating that edge is a Rome Road. - The next line contains two decimals .
- The last line contains two decimals .
Output Format
Output the length of the shortest path between nodes and , with digits after the decimal point.
100.0 2.0
2
1.0 0.0
2.0 1.0
1 2
0 0
0.0 0.0
2.0 2.0
202.8284
Hint
Constraints (for of the testdata):
- .
- .
- .
- .
- .
- The number of Rome Road edges does not exceed .
- (excluding the end marker).
- .
Here denotes the number of digits after the decimal point of decimal .
Translated by ChatGPT 5
京公网安备 11011102002149号