PROGRAMMING:Bridge short geometry
In a NxN Boolean matrix, 0 represents water, 1 represents land, and the largest area enclosed by 1 is an island. Assuming that there are only two islands in the matrix, please calculate the length of the shortest bridge connecting the two islands (bridging is equivalent to turning 0 to 1 to connect the two islands).
###Input sample 1:
The first line is a positive integer n (the value range is [2 -- 100]).
Next, n rows of 0 or 1 separated by spaces, n for each row (0 for water, 1 for land).
```in
three
0 0 1
0 0 1
1 1 0
```
###Output sample 1:
A positive integer representing the length of the shortest bridge. In this case, the middle or lower right corner is feasible.
```out
one
```
###Input sample 2:
The first line is a positive integer n (the value range is [2 -- 100]).
Next, n rows of 0 or 1 separated by spaces, n for each row (0 for water, 1 for land).
```in
five
1 1 1 1 1
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 1
```
###Output sample 2:
A positive integer representing the length of the shortest bridge. In this case, the last line is a feasible solution.
```out
three
```
answer:If there is no answer, please comment
###Input sample 1:
The first line is a positive integer n (the value range is [2 -- 100]).
Next, n rows of 0 or 1 separated by spaces, n for each row (0 for water, 1 for land).
```in
three
0 0 1
0 0 1
1 1 0
```
###Output sample 1:
A positive integer representing the length of the shortest bridge. In this case, the middle or lower right corner is feasible.
```out
one
```
###Input sample 2:
The first line is a positive integer n (the value range is [2 -- 100]).
Next, n rows of 0 or 1 separated by spaces, n for each row (0 for water, 1 for land).
```in
five
1 1 1 1 1
1 0 0 0 0
1 0 0 0 0
1 0 0 0 0
1 0 0 0 1
```
###Output sample 2:
A positive integer representing the length of the shortest bridge. In this case, the last line is a feasible solution.
```out
three
```
answer:If there is no answer, please comment