当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5889:Barricade

题目描述
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.
输入解释
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$.
输出解释
For each test cases, output the minimum wood cost.
输入样例
1
4 4
1 2 1
2 4 2
3 1 3
4 3 4
输出样例
4
来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5889

最后修改于 2020-10-25T23:26:28+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1000MS(Java/Others) 65536/65536K(Java/Others)