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

Barricade

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 3438    Accepted Submission(s): 933


Problem Description
The empire is under attack again. The general of empire is planning to defend his castle. The land can be seen as $N$ towns and $M$ roads, and each road has the same length and connects two towns. The town numbered $1$ is where general's castle is located, and the town numbered $N$ is where the enemies are staying. The general supposes that the enemies would choose a shortest path. He knows his army is not ready to fight and he needs more time. Consequently he decides to put some barricades on some roads to slow down his enemies. Now, he asks you to find a way to set these barricades to make sure the enemies would meet at least one of them. Moreover, the barricade on the $i$-th road requires $w_i$ units of wood. Because of lacking resources, you need to use as less wood as possible.
 

Input
The first line of input contains an integer $t$, then $t$ test cases follow.
For each test case, in the first line there are two integers $N(N \leq 1000)$ and $M(M \leq 10000)$.
The $i$-the line of the next $M$ lines describes the $i$-th edge with three integers $u,v$ and $w$ where $0 \leq w \leq 1000$ denoting an edge between $u$ and $v$ of barricade cost $w$.
 

Output
For each test cases, output the minimum wood cost.
 

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

Sample Output
4
 

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 10:27:28, Gzip enabled