Logo
(追記) (追記ここまで)

31753번 - Clever Cell Choices 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
6 초 1024 MB46322969.048%

문제

Two players play the following game on an $N \times M$ 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 $N$ and $M$ (1ドル ≤ N, M ≤ 50$) indicating the dimensions of the grid.

Each of the next $N$ lines contains a string of length $M$. In the $i$-th string, the $j$-th character describes the initial state of cell $(i, j)$. 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

힌트

출처

ICPC > Regionals > Latin America > Latin America Championship > The 2024 ICPC Latin America Championship C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /