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

13746번 - Islands 다국어

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

문제

You are mapping a faraway planet using a satellite. The planet's surface can be modeled as a grid. The satellite has captured an image of the surface. Each grid square is either land (denoted as 'L'), water (denoted as 'W'), or covered by clouds (denoted as 'C'). Clouds mean that the surface could either be land or water; you cannot tell.

An island is a region of land where every grid cell in the island is connected to every other by some path, and every leg of the path only goes up, down, left or right.

Given an image, determine the minimum number of islands that is consistent with the given image.

입력

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input contains two integers, r and c (1 ≤ r,c ≤ 50), which are the number of rows and the number of columns of the image. The next r lines will each contain exactly c characters, consisting only of ‘L’ (representing Land), ‘W’ (representing Water), and ‘C’ (representing Clouds).

출력

Output a single integer, which is the minimum number of islands possible.

제한

예제 입력 1

4 5
CCCCC
CCCCC
CCCCC
CCCCC

예제 출력 1

0

예제 입력 2

3 2
LW
CC
WL

예제 출력 2

1

힌트

출처

ICPC > Regionals > North America > Southeast USA Regional > 2016 Southeast USA Regional Programming Contest > Division 1 G번

ICPC > Regionals > North America > Southeast USA Regional > 2016 Southeast USA Regional Programming Contest > Division 2 F번

ICPC > Regionals > North America > Pacific Northwest Regional > 2016 Pacific Northwest Region Programming Contest > Division 2 T번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2016 Mid-Atlantic Regional Programming Contest F번

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

출처

대학교 대회

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

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