NOTE: This problem contains images that may not be displayed properly if viewed outside the contest applet.
You will be given the layout of a rectangular room as a String[] room,
where each character corresponds to a 1 meter by 1 meter square area of the room.
A '.' (period) indicates an empty square, a '#' indicates a post that covers the square
and extends from the floor to the ceiling, and a '*' (asterik) indicates a light source
at the center of the square.
There will be exactly 1 light source in the room.
The source will illuminate any point on the floor in an empty square
if a straight line from to that point from the light source does not intersect any post.
All other points in empty squares are in shadow.
Given room, compute the area of the floor (in square meters) that is in shadow.
For example, consider the following room layout:
{ ".*#...",
"......",
".#...#",
".....#",
".....#" }
The post below the light casts a shadow of 5.0 square meters,
and the shadow cast by the post to the right of the light has an area of 8.5
square meters, as shown in the figure below.
Therefore, 13.5 is the correct answer.
|