#P1506. 拯救oibh总部

    ID: 497 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟搜索广度优先搜索,BFS深度优先搜索,DFS

拯救oibh总部

Description

oibh was engulfed by a sudden flood. Fortunately, the oibh headquarters has built walls at some important places, denoted by *. A region that is enclosed by walls on all four sides cannot be reached by the flood.

Inside the oibh headquarters, there are many important regions, each represented on the map by a single 0.

Given the wall construction map of oibh, determine how many important regions are not flooded.

Input Format

The first line contains two positive integers x,yx, y.

The next xx lines each contain yy characters, consisting of * and 0, representing the construction map of the oibh headquarters.

Output Format

Output the number of 0 characters in the oibh headquarters that are not flooded.

4 5
00000
00*00
0*0*0
00*00
1

5 5
*****
*0*0*
**0**
*0*0*
*****
5

Hint

For 100%100\% of the testdata, 1x,y5001 \le x, y \le 500.

Translated by ChatGPT 5