hdu 2437 Jerboas (筑图+bfs+取余
发布时间: 2013-09-07 14:12:44 作者: rapoo
hdu 2437 Jerboas (建图+bfs+取余判重)
JerboasTime Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1252 Accepted Submission(s): 327
Problem Description
As far as we know, jerboa burrows in the desert are connected with one-way tunnels. What's more, for some unknown reasons, it's true that start from any burrow, follows the tunnels you can not go back to the starting burrow.
Summer means last-minute of offers on good times, so of course jerboas could not stay behind. One day, a little jerboa Alice who lived in a temporary burrow S wants to migrate to a permanent one. There are different routes she can take, but Alice is so odd that she only selects those whose total travel distances is a multiple of K. Among all routes that Alice may select, we are interested in the shortest one. Can you help to find it out? Of course different routes may lead to different destinations.
InputOutputSample InputSample OutputSource思路:还是蛮裸的bfs,用邻接表存图会快一点,满足是y是k的倍数用取余判重就够了,满足y最小可以用优先队列实现,最后满足z最小就是搜到第一个答案不要急着return就够了。
代码: