| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 13 | 11 | 11 | 91.667% |
Lesya is working as a landscape designer. Her task is to create a road around the lake in the park using as few of construction materials as possible. She can only create the road on the lawn cells.
THe park is a grid of $h \times w$ cells, each cell can be either ground, or lawn, or lake. You are given the park map where lawn cells are shown. It is guaranteed that:
Lesya must design the road by replacing some lawn cells with road cells, so that the road was 4-looping the lake, and the number of cells in the road was as small as possible.
Help her to come up with the optimal road plan.
The first line contains two integers $h$ and $w$ ($3 \le h, w \le 1000$).
Each of the next $h$ lines contains $w$ characters "." and "#" denoting land/lake and lawn, respectively.
It is guaranteed that the lawn in 4-connected and contains exactly one inner 4-connected area.
Output $h$ lines with $w$ characters each --- the optimal plan of the road. The character '#' denotes the road cell, the character '.' denotes any other cell. Note that the road can only be built on lawn cells.
If there are several optimal plans to build the road, you can output any of them.
4 6 ###### #.#.## #...#. #####.
#####. #...#. #...#. #####.