#P15803. [GESP202603 七级] 物流网络
[GESP202603 七级] 物流网络
Background
Related multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1211.
Problem Description
A logistics network consists of cities and bidirectional roads. Each road has two attributes:
- Transport cost .
- Scenic rating .
When a truck transports goods from city to city , it needs to pay the sum of the transport costs of the roads it travels on.
To promote tourist routes, the logistics company offers a discount policy: along the transport path, the transport cost of the road with the highest scenic rating can be waived. If there are multiple roads whose scenic rating ties for the maximum, only the cost of one of them is waived.
Please compute the minimum transport cost from city to city .
Input Format
The first line contains two integers , representing the number of cities and the number of roads.
The next lines each contain four integers , indicating a bidirectional road connecting city and city , where is the transport cost and is the scenic rating.
Output Format
Output one integer, representing the minimum cost from city to city .
If city cannot be reached, output -1.
3 3
1 2 10 5
2 3 20 6
1 3 100 1
0
Hint
Sample Explanation
Path : cost , maximum scenic rating (edge ). Waive , total cost .
Path : cost , maximum scenic rating (edge ). Waive , total cost .
Constraints
, , .
Translated by ChatGPT 5