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

20252번 - Garden 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
10 초 1024 MB61231240.000%

문제

There is a rectangle garden in front of Gina’s house. The garden can be seen as an n-by-m rectangular grid. All grid cells are identical squares, and two grid cells are considered adjacent if they share an common edge.

Gina loves cacti and wants to plant as many cacti as possible in the garden. However, there are some constraints on planting cacti.

  • The soil can be too wet in some of the cells and therefore is not suitable for cacti. Gina cannot plant cacti in those cells.
  • Since the soil in each cell is not fertile enough to grow two or more cacti, Gina may plant at most one cactus in a cell.
  • At most one cactus can be planted in any pair of adjacent cells. Otherwise, the cacti in those cells may be harmed by their neighbor’s thorns.

Please write a program to help Gina calculate the maximum possible number of cacti can be planted, and also a way of plantings that meet the listed constraints.

입력

The first line contains two space-separated integers n and m meaning the garden is an n-by-m grid. Then, each of the following n lines contains a string of m characters. These characters are either ‘.’ or ‘*’. The j-th character of the i-th of these lines indicates whether the soil in the grid cell on the i-th row and the j-th column is suitable for planting a cactus. ‘.’ means it is suitable, and ‘*’ means it is not suitable.

출력

First, output the maximum possible number of cacti on the first line. Then, output n lines, each line containing a string of m characters. Each of the characters must be one of ‘.’, ‘*’ and ‘C’. The j-th character of the i-th of these lines indicates the status of the grid cell on the i-th row and the j-th column. A ‘C’ means a cactus should be planted in that particular cell, and the other cells should be identical to the corresponding position of the input.

If there are more than one possible way of planting, any of them will be accepted.

제한

  • 1 ≤ nm ≤ 105

예제 입력 1

3 3
*.*
...
*.*

예제 출력 1

4
*C*
C.C
*C*

예제 입력 2

2 4
*..*
....

예제 출력 2

3
*C.*
C.C.

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2020 G번

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

출처

대학교 대회

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

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