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

建议使用的浏览器:

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

5870:Alice's Adventure in Wonderland

题目描述
Alice studies in one university in Dalian. You may not know that she is an idiot in finding the right way to somewhere. One day, she got lost on her way to a teaching building. Believe it or not, she got lost on the campus where she had lived for three years. By the way, she is a little lazy, so she always chooses the shortest possible way to go.
  
  Last night, Alice had a dream that she was in Wonderland. She was shown a map of this place. As far as she can remember, there are $N$ towns numbered from 1 to $N$, connected by $M$ bi-directed roads. Now, she was in the #$1$ town, heading for the #$N$ town. Alice had an ability in her dream that she could build another (only one) road not existing on the map before, the length was arbitrarily selected by Alice. Note that multiple edges and self-loops are not allowed after the edge added.
  
  Now, she gets an idea that she adds one road so that the number of the shortest paths from the #$1$ town to the #$N$ town increased would be no less than $X$ ($X$ is given). To get the job done, Alice needs to choose two distinct towns which are not yet connected directly by an existing road and then links them up with a new road. As to the weight, it is a positive integer determined at her will. By the way, Alice is quite clever much of the time, but sometimes gets confused just for no reason and unfortunately, in her dream, she was confused by this problem. Alice wanted to know how many different choices she had when choosing those two towns. Note that choosing town A and B is considered the same as choosing town B and A. Can you help her?
输入解释
There are several test cases. For each case, the first line contains two integers $N$ and $M$ as described above. The second line is an integer $X$. Then $M$ lines follow, each contains three integers $u, v, w$ meaning a bi-directed road between $u$ and $v$ of length $w$. Tests end with the case $N=M=0$, which shouldn't be processed.

You can assume that
  
    $2\le N\le20 000$
    
     $0\le M \le 100 000$
    
     $1\le u,v \le N$
    
     $1\le w\le 10 000$
    
     $1\le X\le 1000 000 000$
输出解释
For each case output the answer on a single line.
输入样例
3 2
1
1 2 1
2 3 1
0 0
输出样例
1
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5870

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

共提交 0

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