|
||||||||||
Legal pathTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 687 Accepted Submission(s): 188 Problem Description Given a directed graph ,every edge has a weight. A legal route is defined as the list of edge, for every edge's weight should at least K greater than last edge's weight,if the last one exist. the length of a legal route is the total weight of the edge on it. We should find the legal path from node $1$ to node $n$ of minimum length. Input There is a number \(T\) shows there are T test cases below. ($T \leq 10$) For each test case , the first line contains three integers $n , m , K$, $n , m$ means the number of nodes and the number of edges on the graph. In following there are $m$ lines. Each line has three integer $x , y , z$. indicate that there is an edge frome $x$ to $y$ weighted $z$. $2 \leq n \leq 100,000$ $0 \leq m \leq 200,000$ $1 \leq K,z \leq 1,000,000,000$ $1 \leq x,y \leq n$ Output For each case ,if there is no legal path from $1$ to $n$, output -1 ,otherwise output the answer. Sample Input
Sample Output
Source | ||||||||||
|