#P4162. [SCOI2009] 最长距离
[SCOI2009] 最长距离
Description
windy has a rectangular piece of land divided into small cells. Some cells contain obstacles. If cell A can reach cell B, then the distance between them is defined as the Euclidean distance between their centers. If cell A cannot reach cell B, then there is no distance between them. If cells X and Y share a common edge and both X and Y contain no obstacles, you can move from X to Y. If windy can remove obstacles, find the maximum distance over all pairs of cells (considering only pairs where one can reach the other). It is guaranteed that after removing obstacles, at least one cell contains no obstacle.
Input Format
The first line contains three integers, . Then there are lines, each containing a string of length , where 0 denotes an empty cell and 1 denotes a cell containing an obstacle.
Output Format
Output a single floating-point number, with digits after the decimal point.
3 3 0
001
001
110
1.414214
4 3 0
001
001
011
000
3.605551
3 3 1
001
001
001
2.828427
Hint
- For of the testdata, and .
- For of the testdata, and .
- For of the testdata, and .
Translated by ChatGPT 5
京公网安备 11011102002149号