#P4162. [SCOI2009] 最长距离

[SCOI2009] 最长距离

Description

windy has a rectangular piece of land divided into N×MN\times M small 1×11\times 1 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 TT 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 TT obstacles, at least one cell contains no obstacle.

Input Format

The first line contains three integers, N,M,TN,M,T. Then there are NN lines, each containing a string of length MM, where 0 denotes an empty cell and 1 denotes a cell containing an obstacle.

Output Format

Output a single floating-point number, with 66 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 20%20\% of the testdata, 1N,M301 \le N,M \le 30 and 0T0 0 \le T \le 0 .
  • For 40%40\% of the testdata, 1N,M301 \le N,M \le 30 and 0T2 0 \le T \le 2 .
  • For 100%100\% of the testdata, 1N,M301 \le N,M \le 30 and 0T30 0 \le T \le 30.

Translated by ChatGPT 5