아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Storing Eggs

면접 대비

시간 제한2초메모리 제한1024 MB

요약
3×N 격자의 사용 가능한 칸 중 K개를 골라 두 알 사이 최소 유클리드 거리를 최대화하고, K개를 놓을 수 없으면 -1을 출력한다.
난이도

보통10점 중 6점

유형
이분 탐색, 그리디, 기하, 완전 탐색
정답자
아직 제출이 없습니다

문제

You have an egg carton that can be represented as a 3×N3 \times N grid. The grid consists of 33 rows, numbered from 11 to 33, and NN columns, numbered from 11 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 11 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 (r_1,c_1)(r\_1, c\_1) and another egg in cell (r_2,c_2)(r\_2, c\_2) can be calculated using Euclidean distance, i.e. (r_1−r_2)2+(c_1−c_2)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 (1≤N≤1001 ≤ N ≤ 100; 2≤K≤3N2 ≤ K ≤ 3N) representing the number of columns of your egg carton and the number of eggs. Each of the next 33 lines contains a string S_rS\_r of length NN that consists of either character ‘.’ or ‘#’. The cth character of string S_rS\_r represents the condition of cell (r,c)(r, c) of the carton. Cell (r,c)(r, c) is usable if S_r,c=S\_{r,c} = ‘.’ and unusable if S_r,c=S\_{r,c} = ‘#’.

출력

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 10−610^{-6}.

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

예제4

  1. 예제 1

    입력
    5 2
    #....
    .....
    ....#
    
    예상 출력
    4.472136
    
  2. 예제 2

    입력
    5 6
    ##.##
    #####
    .....
    
    예상 출력
    1.000000
    
  3. 예제 3

    입력
    3 4
    ..#
    ...
    ...
    
    예상 출력
    1.414214
    
  4. 예제 4

    입력
    2 6
    ..
    .#
    ..
    
    예상 출력
    -1