Storing Eggs
면접 대비시간 제한2초메모리 제한1024 MB
3×N 격자의 사용 가능한 칸 중 K개를 골라 두 알 사이 최소 유클리드 거리를 최대화하고, K개를 놓을 수 없으면 -1을 출력한다.
문제
You have an egg carton that can be represented as a grid. The grid consists of rows, numbered from to , and columns, numbered from to . The cell at row and column is denoted as . Each cell can be either usable or unusable; each usable cell can only hold at most egg while unusable cells, as the name implies, cannot be used.
You want to put exactly 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 and another egg in cell can be calculated using Euclidean distance, i.e. .
Determine the maximum possible distance between any two closest eggs, or determine if it is impossible to put eggs into your carton.
입력
Input begins with two integers (; ) representing the number of columns of your egg carton and the number of eggs. Each of the next lines contains a string of length that consists of either character ‘.’ or ‘#’. The cth character of string represents the condition of cell of the carton. Cell is usable if ‘.’ and unusable if ‘#’.
출력
If 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 .
If eggs cannot be put into your carton, then output -1 in a single line.