#P2825. [HEOI2016/TJOI2016] 游戏

    ID: 1881 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2016各省省选网络流河北连通块二分图天津

[HEOI2016/TJOI2016] 游戏

Description

In 2016, Sister Jiayuan fell in love with a game called BnB.

Simply put, in this game you place several bombs on a map to see whether you can hit the opponent or avoid the opponent’s bombs. While playing, Little H thought of this question: given a map, what is the maximum number of bombs you can place so that no two bombs can hit each other? A bomb’s explosion reaches the entire row and column where it is placed. The explosion can pass through soft stones, but cannot pass through hard stones.

You are given an n×m n \times m grid map: the symbol * denotes an empty cell; the explosion can pass through it, and you can place a bomb on it. The symbol x denotes a soft stone; the explosion can pass through it, but you cannot place a bomb on it. The symbol # denotes a hard stone; the explosion cannot pass through it, and you cannot place a bomb on it. For example, given a 1×4 1 \times 4 grid map *xx*, you can place at most one bomb on this map. Given another 1×4 1 \times 4 grid map *x#*, you can place at most two bombs on this map.

Now, given any n×m n \times m grid map from Little H, determine the maximum number of bombs that can be placed.

Input Format

The first line contains two positive integers n,m n, m , where n n is the number of rows and m m is the number of columns.

Then n n lines follow, each containing m m characters representing the grid map. The number of * does not exceed n×m n \times m .

Output Format

Output a single integer a a , the maximum number of bombs that can be placed.

4 4
#***
*#**
**#*
xxx#
5

Hint

1n,m501 \leq n, m \leq 50.

Translated by ChatGPT 5