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

33185번 - Star Wars 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB57302549.020%

문제

Amirreza is playing the Star Wars game. This game is played on an $n \times m$ board where each cell is either empty (‘.’), contains a white piece (‘W’) or a black piece (‘B’). At start of the game, Amirreza should choose exactly one white piece to play with. Afterwards he can move this piece multiple times to knock out as many black pieces as possible. Suppose the white piece is currently in cell $(i, j)$ of the board; In one move, this piece can go up-left $(i - 1, j - 1),ドル up $(i - 1, j)$ or up-right $(i - 1, j + 1),ドル provided that cell exists on the board and it does not contains another white piece. If the cell contains a black piece, it will be knocked out. Help Amireza figure out the maximum number of black pieces he can knock out.

입력

The first line contains two integers $n$ and $m$ (1ドル \le n, m \le 50$), the number of rows and columns in the board, respectively. This is followed by $n$ lines, each containing $m$ characters. The $j$th character of the $(i + 1)$th line represents cell $(i, j)$. Each character is ‘W’, ‘B’, or ‘.’, denoting a white piece, a black piece, or an empty cell, respectively.

출력

Print a single integer, the maximum number of black pieces Amirreza can knock out.

제한

예제 입력 1

8 10
.W...BB...
W..B.WB...
.B.WB...W.
.B..B.....
..W...BB..
B.B..B.W.W
.WB.W...B.
..W..BW.B.

예제 출력 1

5

힌트

출처

ICPC > Regionals > Asia West Continent > Iran > 2023 ICPC Asia Tehran Regional Contest H번

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

출처

대학교 대회

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

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