시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
10 초 | 1024 MB | 47 | 14 | 5 | 23.810% |
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.
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.
3 3 *.* ... *.*
4 *C* C.C *C*
2 4 *..* ....
3 *C.* C.C.
ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2020 G번