Moon in the Photo
InterviewTime limit2sMemory limit512 MB
Find the largest circle that contains no black pixels in a grid of white and black points, and print its radius and center as column then row.
- Level
Easy3 of 10
- Topics
- Brute force, Geometry
- Solved
- No attempts yet
Problem
Dasha is a beginner astronomer who finally bought a digital camera. Taking pictures of the night sky with a button press and studying them later is much more convenient.
The camera sensor does not have a high resolution, and night photos show only two colors, black and white. Dasha has already taken a huge number of pictures, and her memory card is not full yet. She wants to know where the Moon is in each photo.
The Moon looks like a circle with center point and a non-negative integer radius . In other words, it is the set of white points whose distance from is at most . The Moon fits entirely inside the photo.
Some bright stars may also appear as single white points. There are at most 25 of them. No other objects appear in the photo.

Write a program that finds the largest possible radius of a circle that matches the Moon, along with a possible position of its center.
Input
The first line contains integers and , the horizontal and vertical resolution of the photo (). Each of the next lines contains characters, either "." (black point) or "*" (white point).
Output
On the first line, print the maximum radius of the Moon as a natural number. On the second line, print the coordinates of the Moon's center for that radius, column first and then row. Columns and rows are numbered from 1, left to right and top to bottom, respectively.
If there are several possible centers, print any of them. It is guaranteed that a valid answer exists.