编程介的小学生 2019-06-27 21:37 采纳率: 20.5%
浏览 181

需要多就能抓住小偷的计算,要求的是采用的C语言的程序的编写的过程来实现的程序的做法

Problem Description
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.

Input
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;

Output
print a line contains a integer respect the days in worst situation;

Sample Input
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

Sample Output
2
3

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog