logo AlgoBeat OnlineJudge
登录 注册

#215249. [ICPC 2024 LAC] Clever Cell Choices

内存限制:1024 MiB 时间限制:6000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Two players play the following game on an grid:

  • Initially each cell of the grid is either empty or occupied.
  • Players take turns placing a stone on an empty cell, occupying the cell. Each new stone must be adjacent to the last placed stone, with the exception of the starting stone that can be placed on any empty cell. A stone is adjacent to another stone if they are located in two cells that share a side.
  • The game ends whenever a player cannot place a stone according to the above rules. In that case, the player who cannot place a stone loses the game, and the other player wins.

A winning starting cell is a cell such that the first player wins the game if they place their starting stone there, assuming both players play optimally. Given a description of the initial grid, you must tell how many winning starting cells it has.

输入格式

The first line contains two integers and () indicating the dimensions of the grid.

Each of the next lines contains a string of length . In the -th string, the -th character describes the initial state of cell . The character is either "." (dot) denoting an empty cell, or "#" (hash) representing an occupied cell.

输出格式

Output a single line with an integer indicating the number of winning starting cells.

样例

样例输入 1

3 3
#.#
...
#.#

样例输出 1

4

样例输入 2

3 3
..#
...
...

样例输出 2

0

样例输入 3

1 4
...#

样例输出 3

2