Clever Cell Choices
시간 제한6초메모리 제한1024 MB
양쪽이 최선을 다할 때, 빈 칸 중 선공이 이기는 시작 칸의 개수를 센다.
문제
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.