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

建议使用的浏览器:

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

3606:The police caught the thief

题目描述
In a country, a thief stole the king's jewels, the king was very angry, asked the police to seize he as soon as possible,the thief was afraid of stealing king's jewels, to prevent the police from seizing , he decided to randomly walk in the nearby cities or stay put a day, the police found the thief at “t” City and himself at “s” city, and received information (police can always know where is the thief ). he decided to quickly caughting the thief.The police want to know about how long to seize the thief in the worst situation. This country can be seen as a undirected graph, there are N cities, M edges .As we know the police are very smart and quick; a day he will go to a closer city to the thief, if there are several cities, he will choose the smallest label city, if the thief is not in that city he will continue to go to the next one closer city to the thief . If they have several cities, they will select the smallest label city too, in other word ,a day police can move two steps. Suppose the police move first, please tell the police how many days to seize the thief in worst situation.
输入解释
Multi test cases;  
The first line consist of the two integers N, M (1 ≤ N, M ≤ 1000), separated by spaces; The second line consist of two integers is s, t, respectively, the initial city where the police and thieve The third line to the M +1 line input two integers a and b ,there is one edge between city a and b.,
Processing to the end of the file;
输出解释
print a line contains a integer respect the days in worst situation;
输入样例
4 3 
1 4 
1 2 
2 3 
3 4 
9 9 
9 3 
1 2 
2 3 
3 4 
4 5 
3 6 
4 6 
4 7 
7 8 
8 9 
输出样例
2
3
来自杭电HDUOJ的附加信息
Recommend lcy

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

源链接: HDU-3606

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

共提交 0

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