QOJ.ac

QOJ

実行時間制限: 2 s メモリ制限: 128 MB 満点: 100

#6359. Game

統計

In 2016, Jiayuan fell in love with a game called "Bomb Man." Simply put, the game involves placing several bombs on a map to see if you can hit your opponent or avoid their bombs. While playing, Xiao H thought of the following problem: given a map, what is the maximum number of bombs that can be placed such that no two bombs can hit each other? The range of a bomb covers the row and column it is placed in. The power of a bomb can penetrate soft stones but cannot penetrate hard stones.

Given an $n \times m$ grid map: `represents an empty space. The bomb's power can penetrate it, and a bomb can be placed here. *xrepresents a soft stone. The bomb's power can penetrate it, but a bomb cannot be placed here. *#` represents a hard stone. The bomb's power cannot penetrate it, and a bomb cannot be placed here.

For example, given a $1 \times 4$ grid map *xx*, at most one bomb can be placed on this map. Given another $1 \times 4$ grid map *x#*, at most two bombs can be placed on this map.

Now, given an arbitrary $n \times m$ grid map, find the maximum number of bombs that can be placed.

Input

The first line contains two positive integers $n$ and $m$, representing the number of rows and columns of the map, respectively. $1 \le n, m \le 50$.

The next $n$ lines each contain $m$ characters, representing the grid map.

Output

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

Constraints

For 20% of the data, the number of * does not exceed 20. For 100% of the data, the number of * does not exceed $n \times m$.

Examples

Input 1

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

Output 1

5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.