P24974 [AtCoder] [ARC041B] Amoeba
普及
题目描述

Problem Description

There is a board with $ N $ rows and $ M $ columns. The position of the cell in the $ i $th row ($ 1≦i≦N $) and $ j $th column ($ 1≦j≦M $) is represented as $ (i,j) $.

Initially, there were $ a_{ij} $ amoebas in the cell $ (i,j) $. However, there were no amoebas on the edges of the board. That is, if $ i=1,N $ or $ j=1,M $, then $ a_{ij}=0 $.

When Takahashi shouts loudly, the amoebas are startled and each take the following action:

  • One amoeba splits into four and moves one each to the cells above, below, left, and right.

As a result, there are $ b_{ij} $ amoebas in the cell $ (i,j) $.

Given the current configuration of amoebas $ (b_{ij}) $, find one possible initial configuration $ (a_{ij}) $. Note that at least one such $ (a_{ij}) $ exists.

Input Format

The input is given from the standard input in the following format:

$ N $ $ M $ $ b_{11} $$ b_{12} $$ .. $$ b_{1M} $ $ b_{21} $$ b_{22} $$ .. $$ b_{2M} $ $ : $ $ b_{N1} $$ b_{N2} $$ .. $$ b_{NM} $ - The first line contains the number of rows $ N $ ($ 3≦N≦500 $) and the number of columns $ M $ ($ 3≦M≦500 $) separated by a space. - The next $ N $ lines contain the current configuration of amoebas. The $ i $th line's $ j $th character represents $ b_{ij} $ ($ 0≦b_{ij}≦9 $). ## Output Format Output one possible initial configuration in $ N $ lines. The $ i $th line's $ j $th character should represent $ a_{ij} $. Ensure to include a newline at the end of the output. > $ a_{11} $$ a_{12} $$ .. $$ a_{1M} $ $ a_{21} $$ a_{22} $$ .. $$ a_{2M} $ $ : $ $ a_{N1} $$ a_{N2} $$ .. $$ a_{NM} $

Sample Input and Output

Sample Input #1

3 3
010
101
010

Sample Output #1

000
010
000

Sample Input #2

3 4
0230
2323
0230

Sample Output #2

0000
0230
0000

Sample Input #3

5 5
00100
03040
20903
05060
00300

Sample Output #3

00000
00100
02030
00300
00000

Notes/Hints

None

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 010 101 010
样例输出
000 010 000