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

建议使用的浏览器:

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

6331:Problem M. Walking Plan

题目描述
There are $n$ intersections in Bytetown, connected with $m$ one way streets. Little Q likes sport walking very much, he plans to walk for $q$ days. On the $i$-th day, Little Q plans to start walking at the $s_i$-th intersection, walk through at least $k_i$ streets and finally return to the $t_i$-th intersection.
Little Q's smart phone will record his walking route. Compared to stay healthy, Little Q cares the statistics more. So he wants to minimize the total walking length of each day. Please write a program to help him find the best route.
输入解释
The first line of the input contains an integer $T(1\leq T\leq10)$, denoting the number of test cases.
In each test case, there are $2$ integers $n,m(2\leq n\leq 50,1\leq m\leq 10000)$ in the first line, denoting the number of intersections and one way streets.
In the next $m$ lines, each line contains $3$ integers $u_i,v_i,w_i(1\leq u_i,v_i\leq n,u_i\neq v_i,1\leq w_i\leq 10000)$, denoting a one way street from the intersection $u_i$ to $v_i$, and the length of it is $w_i$.
Then in the next line, there is an integer $q(1\leq q\leq 100000)$, denoting the number of days.
In the next $q$ lines, each line contains $3$ integers $s_i,t_i,k_i(1\leq s_i,t_i\leq n,1\leq k_i\leq 10000)$, describing the walking plan.
输出解释
For each walking plan, print a single line containing an integer, denoting the minimum total walking length. If there is no solution, please print -1.
输入样例
2		
3 3	
1 2 1
2 3 10
3 1 100
3		
1 1 1
1 2 1
1 3 1
2 1	
1 2 1
1		
2 1 1
输出样例
111
1
11
-1
来自杭电HDUOJ的附加信息
Recommend chendu

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

源链接: HDU-6331

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

共提交 0

通过率 --%
时间上限 内存上限
5000/2500MS(Java/Others) 524288/524288K(Java/Others)