#P15616. [ICPC 2022 Jakarta R] Storing Eggs

[ICPC 2022 Jakarta R] Storing Eggs

题目描述

You have an egg carton that can be represented as a 3×N3 \times N grid. The grid consists of 3 rows, numbered from 1 to 3, and NN columns, numbered from 1 to NN. The cell at row rr and column cc is denoted as (r,c)(r, c). Each cell can be either usable or unusable; each usable cell can only hold at most 1 egg while unusable cells, as the name implies, cannot be used.

You want to put exactly KK eggs into usable cells of your carton such that the distance between any two closest eggs is maximized. The distance between an egg in cell (r1,c1)(r_1, c_1) and another egg in cell (r2,c2)(r_2, c_2) can be calculated using Euclidean distance, i.e. (r1r2)2+(c1c2)2\sqrt{(r_1 - r_2)^2 + (c_1 - c_2)^2}.

Determine the maximum possible distance between any two closest eggs, or determine if it is impossible to put KK eggs into your carton.

输入格式

Input begins with two integers NN KK (1N1001 \leq N \leq 100; 2K3N2 \leq K \leq 3N) representing the number of columns of your egg carton and the number of eggs. Each of the next 3 lines contains a string SrS_r of length NN that consists of either character '.' or '#'. The cthc^{th} character of string SrS_r represents the condition of cell (r,c)(r, c) of the carton. Cell (r,c)(r, c) is usable if Sr,c=.S_{r,c} = \tt{.} and unusable if Sr,c=#S_{r,c} = \tt{\#}.

输出格式

If KK eggs can be put into your carton, then output a real number in a single line representing the maximum possible distance between any two closest eggs. Your answer is considered correct if its absolute or relative error does not exceed 10610^{-6}.

If KK eggs cannot be put into your carton, then output 1-1 in a single line.

5 2
#....
.....
....#
4.472136

提示

Explanation for the sample input/output #1

The maximum distance between any two closest eggs can only be achieved by putting the eggs in cells (3,1)(3,1) and (1,5)(1,5), where the distance between the two (closest) eggs is 20\sqrt{20}.