#P1027. [NOIP 2001 提高组] Car 的旅行路线
[NOIP 2001 提高组] Car 的旅行路线
Description
It is summer vacation again. Car, who lives in city A, wants to travel with her friends.
She knows that each city has airports located at the vertices of a rectangle. Between any two airports within the same city, there is a straight high-speed railway; in the -th city, the unit distance cost of the high-speed railway is . Between any two airports in different cities, there is a flight route, and the unit distance cost of all flight routes is .

Note: The figure does not show all railways and flight routes.
How should Car plan her route to city B to minimize the expense? She finds this is not a simple problem and asks you for help.
Find a travel route from city A to city B. The departure and arrival airports within their respective cities can be chosen arbitrarily. Minimize the total cost.
Input Format
The first line contains a positive integer , the number of test cases.
For each test case:
- The first line contains positive integers .
- is the number of cities.
- is the unit distance cost for flights.
- and are the indices of city A and city B, respectively.
- The next lines each contain positive integers $x_{i1}, y_{i1}, x_{i2}, y_{i2}, x_{i3}, y_{i3}, T_i$. Here , , and are the coordinates of any airports in the -th city, and is the unit distance cost of the high-speed railway in the -th city.
Output Format
Output lines, one value per test case.
Round to one decimal place.
1
3 10 1 3
1 1 1 3 3 1 30
2 5 7 4 5 2 1
8 6 8 8 11 6 3
47.5
Hint
Constraints
For of the testdata, , , , $0 \le t, x_{i1}, y_{i1}, x_{i2}, y_{i2}, x_{i3}, y_{i3}, T_i \le 500$.
Source
NOIP 2001 Senior, Problem 4.
Translated by ChatGPT 5
京公网安备 11011102002149号