시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 79 | 45 | 44 | 56.410% |
While browsing a kiosk at a recent trip, you bought a magazine filled with various kinds of logic puzzles. After a while of solving, however, you start to get a bit bored of the puzzles. Still wanting to complete all the puzzles in the magazine, you start wondering about ways to solve some of them algorithmically.
The puzzle you are currently trying to solve is called Mosaic, and it is quite similar to the classic Minesweeper video game:
Figure L.1: Illustration of the first sample
You are given a two-dimensional grid of cells, initially all white, and you have to color some of the cells in black. You are also given a grid of clue numbers, which extends beyond the borders of the puzzle grid by one cell in each direction. The number in a cell indicates (exactly) how many cells in the 3 × 3 block centered at this cell need to be colored in black. You may not color any cells outside of the original grid.
The input consists of:
If the given clue numbers are inconsistent, output impossible. Otherwise, output h lines with w characters each, the solution to the puzzle. Use X for black cells and . for white cells. If there are multiple solutions, any of them will be accepted.
2 3 1 1 2 1 1 1 2 3 2 1 1 2 3 2 1 0 1 1 1 0
X.X .X.
1 2 0 0 1 1 0 1 1 1 0 1 1 1
impossible