#P1608. 路径统计
路径统计
Description
The staff at the “RP Restaurant” are quite something. After unanimously calculating the same phone number, they are about to send HZH and TZY to deliver takeout. They drew a map of their city. On this map, there are locations. They are currently at the town labeled “1,” and the delivery destination is the town labeled “N.” In addition, all roads are one-way. The time cost from town to town is . To deliver the food more efficiently, they want to take a route from town to town with the minimal cost. However, just before departure, they bumped into FYY, who was angry due to a traffic jam, and were inspired: it is not enough to know only one route. So, they invited FYY to study the next problem together: how many minimal-cost paths are there?
Input Format
The first line contains two space-separated integers , indicating the number of towns and the number of edges in the map.
Each of the next lines contains three integers , meaning there is a directed road from town to town with cost . Note that edge records in the testdata may be duplicated, but it is guaranteed that and .
Output Format
Output two numbers: the minimal cost and the total number of minimal-cost paths. It is guaranteed that the total number of minimal-cost paths does not exceed .
Two shortest path solutions are considered different if their path lengths are equal (both are the shortest path length) and the sequences of node indices visited on the shortest paths are different.
If city is unreachable, output only No answer.
5 4
1 5 4
1 2 2
2 5 2
4 1 1
4 2
Hint
- For of the testdata, .
- For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号