1311. Chase

单点时限: 2.0 sec

内存限制: 256 MB

Write a program that:

1.reads the description of a board and numbers of squares on which pieces are placed initially.

2.decides if player B can catch player A and if so, computes how many turns he needs (we assume that both players play optimally);

3.writes the result.

输入格式

In the first line of the input file GON.IN there are four integers n, m, a and b separated by single spaces, where 2<=n<=3000, n-1<=m<=15000, 1<=a,b<=n and a <b. These are (respectively): the number of squares of the board, the number of adjacent (unordered) pairs, the number of the square on which the piece of player A is placed, the number of the square on which the piece of player B is placed. In each of the following lines there are two distinct positive integers separated by a single space, which donote numbers of adjacent squares.

输出格式

In the first and only line there should be:

1.one word NIE (which means NO in Polish), if player B can not catch player A, or

2.one integer - the number of turns needed by B to catch A (if B can catch A).

样例

Input
9 11 9 4
1 2
3 2
1 4
4 7
7 5
5 1
6 9
8 5
9 8
5 3
4 8
Output
3

1 人解决,1 人已尝试。

1 份提交通过,共有 3 份提交。

9.3 EMB 奖励。

创建: 17 年,4 月前.

修改: 7 年,3 月前.

最后提交: 12 年,1 月前.

来源: POI 1998 III Stage

题目标签