아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Mines - 10

시간 제한1초메모리 제한512 MB

요약
H x W 격자의 각 칸에 대해 주변 8칸을 포함한 지뢰 개수가 주어질 때, 조건을 만족하는 지뢰 배치 하나를 복원한다.
난이도

보통10점 중 4점

유형
시뮬레이션, 구현, 그리디
정답자
아직 제출이 없습니다

문제

Heino drew an H × W grid. Each cell was either empty or contained a mine. Indrek, a good friend of Heino, drew another H × W grid. In each cell of his grid, he wrote the total number of mines in the corresponding cell of Heino’s grid and all its adjacent cells (two cells are adjacent if they share a common point). Indrek then erased Heino’s grid. Given Indrek’s grid, your task is to help Heino restore his original grid.

You may assume that at least one solution always exists.

입력

The first line of the input file contains two integers: H (1 ≤ H ≤ 600), the height of the grid, and W (1 ≤ W ≤ 600), the width of the grid. The following H lines each containing W digits describe Indrek’s grid.

출력

The output file should contain H lines. Each of these lines should contain W characters: ‘X’ for a mine and ‘.’ for an empty cell.

If there are several correct solutions, submit any one of them.

힌트

In this task you’re given 10 input files named minestest01.in, minestest02.in, minestest03.in, minestest04.in, minestest05.in, minestest06.in, minestest07.in, minestest08.in, minestest09.in, minestest10.in and as a solution you need to submit corresponding output files. You should not submit a program.

예제1

  1. 예제 1

    입력
    3 5
    24531
    46631
    34310
    
    예상 출력
    .XXX.
    .XX..
    XX...