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

建议使用的浏览器:

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

6582:Path

题目描述
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.
输入解释
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$.
输出解释
Print $T$ lines, each line containing a integer, the answer.
输入样例
1
3 4
1 2 1
2 3 1
1 3 2
1 3 3
输出样例
3
来自杭电HDUOJ的附加信息
Recommend

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

源链接: HDU-6582

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

共提交 0

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