Distribution Center
시간 제한4초메모리 제한2048 MB
밀어서 목적지에 도달할 수 없는 모든 칸을 표시한다. 미는 사람은 어디에든 있을 수 있다고 가정한다.
문제
Sokoban is the best employee at your town's biggest distribution center. He likes his job because it is simple, albeit a bit physically intensive. Everyday he is pushing crates to some possbile destinations from where they will be loaded in trucks. Unfortunately, Sokoban's youth is behind him, so he starts to feel the effects of the physical labour. Therfore, he came up with an algorithm to help him move the crates optimally: the Fast Pushing Crates (FPC) algorithm. For the algorithm to be complete, he needs a bit of help from you.
His algorithm receives as input the layout of the distribution center, as a grid, and returns the steps he needs to take to efficiently push the crates. In his algorithm, he needs to find out which squares in the grid are dead squares. We call a square a dead square if it is a wall or if it is impossible to push a crate from that square to any of the destinations (even if Sokoban could teleport to any location).
Given the layout of the distribution center, help Sokoban find out which squares are dead squares.
입력
The input consists of:
-
A line with two integers and (), the number of rows and columns of the grid.
-
lines, each containing characters, where:
- A '
\#' represents a wall. It is guaranteed that the grid is surrounded by walls. - A '
D' represents a destination. There can be any number of them, including . - A '
.' represents an empty square.
- A '
출력
Output lines, each containing characters, where the th character of the th line is:
- '
X' if the square at position is a dead square. - '
O' otherwise.