#00021D

mit-indiv09-shtpaths

A graph has up to 5000 vertices labeled by integers between -1000000 and 1000000 inclusive. Find the shortest path between two given vertices.



InputThe input begins with a line ”A B,” where A is the start vertex and B is the end vertex. Each subsequent line contains two integers ”C D” and indicates that there is a directed edge from vertex C to D with cost (C+D)*D.


OutputThe output is a single line containing the cost of the shortest (i.e. least-cost) path from A to B. If there is no path, output ”No path”



Input:
0 5
0 5

Output:
25



Input:
0 1
1 0

Output:
No path

Submit solution

Coming later

The grading service will be connected in a later migration step. You can inspect the task and your previous results now.