OTHS Coding Competition 2 P5 - Coffee Jelly

View as PDF

Submit solution


Points: 7
Time limit: 1.0s
Python 2.0s
Memory limit: 512M

Author:
Problem type

Saiki has bought some of his favourite coffee jelly and wishes to enjoy his treats in peace and quiet.

The school is mapped as a rectangle of length n and width m. Using his psychic powers, Saiki has created a 2d map of the single floored school, where X marks the walls and doors, * represents people and . represents open space. A classroom is a group of open space cells vertically or horizontally connected. A classroom is considered empty if none of the open cells are vertically or horizontally connected to a person.

Saiki wants to enjoy his treats alone, so he asks you: how many empty classrooms are there where he can enjoy his treats?

Constraints

1 \leq n,m \leq 1000

Input Specification

The first line contains 2 non-negative integers n and m.

The following n lines will each contain m characters, representing the school.

Output Specification

Output the number of empty classrooms in the school.

Sample Input 1

6 10
XXXXXXXXXX
X.*.X..X.X
XX.XXXXXXX
XXXX..XXXX
*.......XX
XXXXXXXXXX

Sample Output 1

2

Explanation for Sample Output 1

4 groups of open cells exist, 2 of which do not contain people.

Sample Input 2

7 6
XXX..X
..XXX*
XXXXXX
..*...
XXXXXX
XXXXX.
......

Sample Output 2

3

Explanation for Sample Output 2

5 groups of open cells exist, 3 of which do not contain people.


Comments

There are no comments at the moment.