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

27570번 - Chocolate Chip Fabrication 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB120675959.596%

문제

You are making a chocolate chip cookie using a machine that has a rectangular pan composed of unit squares. You have determined the shape of your cookie, which occupies some squares in that area. Each square of your cookie must be chocolate chipified.

To make the cookie you will repeatedly perform the following two steps:

  1. You place cookie dough in some unit squares.
  2. You expose the cookie dough to a shallow chocolate chip solution. Any cookie dough square that does not have all four adjacent squares (up, down, left, right) filled with cookie dough becomes chocolate chipified. Note that any cookie dough in a square on the boundary of the pan always gets chipified.

The following example shows how to make a cookie of the shape shown on the left (s):

 (s) (a1) (a2) (b1) (b2) 
 -X-X- -D-D- -C-C- -C-C- -C-C-
 XXXXX -D-D- -C-C- DCDCD CCCCC
 XXXXX -DDD- -CCC- DCCCD CCCCC
 -XXX- --D-- --C-- -DCD- -CCC-
 --X-- ----- ----- --D-- --C--

First you place cookie dough in 8ドル$ squares (a1). All squares become chipified after the first solution exposure (a2). You place cookie dough in 8ドル$ more squares (b1). The second exposure makes every square chipified and completes the cookie (b2).

Your chocolate chip solution is expensive, so you want to ensure that you perform the exposure as few times as possible. Given a cookie shape, determine the minimum number of chocolate chip solution exposures required to make the cookie.

입력

The first line of input contains two integers $n$ and $m$ (1ドル \leq n, m \leq 1,000円$), indicating the pan has $n$ rows and $m$ columns of unit squares.

Each of the next $n$ lines contains a string of exactly $m$ characters, where each character is either "X", representing a square occupied by your cookie, or "-", representing an empty square.

The shape of your cookie occupies at least one square. Note that the shape may consist of multiple pieces that are disconnected.

출력

Output the minimum number of chocolate chip solution exposures required to make your cookie.

제한

예제 입력 1

5 5
-X-X-
XXXXX
XXXXX
-XXX-
--X--

예제 출력 1

2

예제 입력 2

4 5
--XXX
--X-X
X-XXX
XX---

예제 출력 2

1

예제 입력 3

5 5
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX

예제 출력 3

3

힌트

출처

ICPC > Regionals > North America > Mid-Atlantic Regional > 2022 Mid-Atlantic USA Regional Contest > Division 1 C번

ICPC > Regionals > North America > South Central USA Regional > 2022 South Central USA Regional Contest > Division 1 C번

ICPC > Regionals > North America > Southeast USA Regional > 2022 Southeast USA Regional Programming Contest > Division 1 C번

ICPC > Regionals > North America > Mid-Atlantic Regional > 2022 Mid-Atlantic USA Regional Contest > Division 2 D번

ICPC > Regionals > North America > South Central USA Regional > 2022 South Central USA Regional Contest > Division 2 D번

ICPC > Regionals > North America > Southeast USA Regional > 2022 Southeast USA Regional Programming Contest > Division 2 D번

ICPC > Regionals > North America > North Central North America Regional > 2022 North Central NA Regional Contest C번

ICPC > Regionals > North America > Pacific Northwest Regional > 2022 ICPC Pacific Northwest Region > Division 2 K번

  • 문제를 만든 사람: Travis Meade
(追記) (追記ここまで)

출처

대학교 대회

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

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