2305. Pirates’ Path

单点时限: 5.0 sec

内存限制: 256 MB

Our captain Jack Sparrow is again on the natives’ island where again the natives think he is a God. But Captain Jack ain’t giving in easily (especially when his life is at stake) and is trying to escape. The island is divided into different areas separated from one another by the many rivers abundant on the island. Two areas are adjacent if they are connected through a bridge. Of course captain Jack has to make it from the area where he’s been kept in captivity to the area where the Black Pearl, his dear ship, is located. Quite unfortunately, the natives are very eager to keep their “God” on the island so they have decided that they will guard some selection of the bridges by putting one man on each selected bridge. Now, our captain, being as unwilling as he is to spend any extra effort whatsoever on a job (as well as desirous of being merciful to his devotees), would like to incapacitate as few natives as possible on his way back. WARNING: Jack needs to make his decision QUICKLY!

输入格式

Input consists of lines where is the number of bridges on the island. The first line contains numbers separated by a single space:

is the number of areas on the island, is the number of bridges, (where ) is the area where Captain Jack is being held and (where ) is the area where the Black Pearl is located. Each of the next lines describes a bridge. The line will contain numbers separated by a single space:

and , are the areas connected by the bridge described by the line and is a bit, either or , indicating whether the bridge is being guarded by a man or not. If it is being guarded, only one man will be a guard.

输出格式

Note that there may not be a path from the area where Captain Jack is being kept to the area of the Black Pearl. If this is the case, output should be a single line containing the following (quotes for clarity):

It’s over with Captain Jack. At least till Pirates of the Caribbean 3.

In case there is a path to the Black Pearl, output should be a single line containing (quotes for clarity):

x native(s) on the easiest way for Captain Jack.

where should be replaced by the least number of natives guarding bridges on a path from the starting area to the area of the Black Pearl.

样例

Input
6 5 1 5
0 1 0
0 2 0
1 2 0
1 3 1
3 4 0
Output
It’s over with Captain Jack. At least till Pirates of the Caribbean 3.
Input
7 11 0 6
0 1 0
0 2 1
1 2 0
1 3 1
2 4 0
1 5 1
3 5 0
3 4 1
3 6 0
4 5 1
5 6 1
Output
1 native(s) on the easiest way for Captain Jack.

15 人解决,28 人已尝试。

29 份提交通过,共有 207 份提交。

6.3 EMB 奖励。

创建: 11 年,5 月前.

修改: 2 年前.

最后提交: 3 周,6 天前.

来源: 2007 Maryland High-school Programming Contest

题目标签