Edge Destruction

5

1 votes
Problem

Given a graph having N vertices and M bidirectional edges, with each edge having some length and some destruction cost. You have to increase the length of the shortest path between vertex 1 and vertex N, for that you can destroy some edges. Find the minimum cost of doing it.

Input Format:
First line consists of two space separated integers denoting N and M.
Following M lines consists of four space separated integers XYDC denoting that there is an edge between vertex X and Y having length D and destruction cost C.

Output Format:
Print the required answer.

Constraints:
2N1000
1M4×105
1X,YN
1D,C1000000

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Currently the shortest path between 1 and 4 is of length 1, so we delete this vertex at a cost of 8, so that the length of shortest path increases to 9.

Editor Image

?