시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB122362530.864%

문제

You have an egg carton that can be represented as a $3 \times N$ grid. The grid consists of $3$ rows, numbered from $1$ to $3$, and $N$ columns, numbered from $1$ to $N$. The cell at row $r$ and column $c$ is denoted as $(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 $K$ 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 $(r_1, c_1)$ and another egg in cell $(r_2, c_2)$ can be calculated using Euclidean distance, i.e. $\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 $K$ eggs into your carton.

입력

Input begins with two integers $N$ $K$ ($1 ≤ N ≤ 100$; $2 ≤ K ≤ 3N$) representing the number of columns of your egg carton and the number of eggs. Each of the next $3$ lines contains a string $S_r$ of length $N$ that consists of either character ‘.’ or ‘#’. The cth character of string $S_r$ represents the condition of cell $(r, c)$ of the carton. Cell $(r, c)$ is usable if $S_{r,c} =$ ‘.’ and unusable if $S_{r,c} =$ ‘#’.

출력

If $K$ 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 $10^{-6}$.

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

예제 입력 1

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

예제 출력 1

4.472136

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

예제 입력 2

5 6
##.##
#####
.....

예제 출력 2

1.000000

There is only one way to put $6$ eggs into the carton; the distance between the two closest eggs is $1$.

예제 입력 3

3 4
..#
...
...

예제 출력 3

1.414214

The maximum distance between any two closest eggs can be achieved by putting the eggs in cells $(1, 1)$, $(3, 1)$, $(3, 3)$, and $(2, 2)$. In this arrangement, the distance of the two closest eggs is $\sqrt{2}$, e.g., between eggs in cells $(1, 1)$ and $(2, 2)$.

Another way to put the eggs while getting the same answer is by putting the eggs in cells $(1, 2)$, $(2, 1)$, $(2, 3)$, and $(3, 2)$.

예제 입력 4

2 6
..
.#
..

예제 출력 4

-1

There are only $5$ usable cells, thus, it is impossible to put $6$ eggs into the carton.