F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Legal path

Time 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
3 3 2 1 1 2 1 2 3 2 3 2 1 1 2 2 2 3 1 4 6 2 1 2 1 1 2 2 2 3 3 1 3 5 2 4 2 3 4 7
 

Sample Output
3 -1 11
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:09:15, Gzip enabled