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

13980번 - Maximum Islands 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB49333278.049%

문제

You are mapping a faraway planet using a satellite.

Your satellite has captured an image of the planet’s surface. The photographed section can be modeled as a grid. Each grid cell is either land, water, or covered by clouds. Clouds mean that the surface could either be land or water, but we can’t tell.

An island is a set of connected land cells. Two cells are considered connected if they share an edge.

Given the image, determine the maximum number of islands that is consistent with the given information.

입력

The first line of input contains two space-separated integers n and m (1 ≤ n, m ≤ 40).

Each of the next n lines contains m characters, describing the satellite image. Land cells are denoted by ‘L’, water cells are denoted by ‘W’, and cells covered by clouds are denoted by ‘C’.

출력

Print, on a single line, a single integer indicating the maximum number of islands that is consistent with the given grid.

제한

예제 입력 1

5 4
LLWL
CCCC
CCCC
CCCC
LWLL

예제 출력 1

8

힌트

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2016 Pacific Northwest Region Programming Contest > Division 1 G번

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

출처

대학교 대회

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

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