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

Path

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 5804    Accepted Submission(s): 1618


Problem Description
Years later, Jerry fell in love with a girl, and he often walks for a long time to pay visits to her. But, because he spends too much time with his girlfriend, Tom feels neglected and wants to prevent him from visiting her.
After doing some research on the neighbourhood, Tom found that the neighbourhood consists of exactly $n$ houses, and some of them are connected with directed road. To visit his girlfriend, Jerry needs to start from his house indexed $1$ and go along the shortest path to hers, indexed $n$.
Now Tom wants to block some of the roads so that Jerry has to walk longer to reach his girl's home, and he found that the cost of blocking a road equals to its length. Now he wants to know the minimum total cost to make Jerry walk longer.
Note, if Jerry can't reach his girl's house in the very beginning, the answer is obviously zero. And you don't need to guarantee that there still exists a way from Jerry's house to his girl's after blocking some edges.
 

Input
The input begins with a line containing one integer $T(1\le T\le 10)$, the number of test cases.
Each test case starts with a line containing two numbers $n,m(1\le n,m\le 10000)$, the number of houses and the number of one-way roads in the neighbourhood.
$m$ lines follow, each of which consists of three integers $x,y,c(1\le x,y\le n,1\le c\le 10^9)$, denoting that there exists a one-way road from the house indexed $x$ to $y$ of length $c$.
 

Output
Print $T$ lines, each line containing a integer, the answer.
 

Sample Input
1 3 4 1 2 1 2 3 1 1 3 2 1 3 3
 

Sample Output
3
 

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-23 16:07:30, Gzip enabled