Refreshment Area
InterviewTime limit2sMemory limit512 MB
Count the number of D-long horizontal or vertical runs of empty cells in an N by M grid.
- Level
Easy2 of 10
- Topics
- Array, Implementation, Brute force, String
- Solved
- No attempts yet
Problem
An international programming contest will be held in Japan, and the venue is being set up now. The venue is divided into a grid of cells in the north-south direction and cells in the east-west direction. Some cells hold contest equipment.
The organizers will set up one refreshment area inside the venue with snacks and drinks, so that contestants can take breaks during the contest. The refreshment area must be consecutive cells in the north-south direction or in the east-west direction. However, the refreshment area cannot be placed on a cell that holds equipment.
Write a program that computes the number of ways to place the refreshment area in the venue.
Input
The input consists of lines.
The first line contains three integers , , (, , ) separated by spaces. The venue is a grid of cells north to south and cells east to west, and the refreshment area is consecutive cells in the north-south or east-west direction.
Each of the next lines contains a string of characters describing the venue. The -th character of the -th of these lines (, ) is either # or . and gives the state of the cell in the -th row from the north and the -th column from the west. # means the cell holds equipment, and . means it does not.
Output
Print the number of ways to place the refreshment area in the venue on one line.
Hint
In the first sample, there are 12 ways in total to place the refreshment area, as shown in the figure below.
