To celebrate being able to reconstruct his array, Max has decided to solve Single Source Shortest Path but wants it to be harder, so he came up with the following problem:
Given a graph of
vertices with bidirectional-weighted edges and toggles for the bits for any given edge weight you travel, find the shortest path from to .
The
You can use multiple toggles on the same edge.
What is the minimum cost to travel from
Constraints
The data are generated such that there is always a path of edges from
Note the increased constraints on
Input Specification
The first line will contain three integers,
The next
The next
Output Specification
Output the minimum distance from
Sample Input
3 3 3
1
2
3
1 3 1
1 2 2
2 3 12
Sample Output
0
Explanation for Sample
It is optimal to take the path
Comments