Problem G: 지뢰 탐색반

Problem G: 지뢰 탐색반

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 161  Solved: 63
[Submit] [Status] [Web Board] [Creator:]

Description

지뢰 찾기 게임을 만들려고 하는데 맵 데이터, 지뢰 값과 비어 있는 공간의 값을 주어 졌을 때
지뢰 주변에 있는 숫자들을 구현 할려고 한다.
주변에 있는 숫자를 어떻게 구현 해야 할지 모르는 지뢰 탐색반인 차차를 위해 도와주자

Input

첫줄에는 테스트 케이스 ( 1 ~ 100 ) 이 들어온다.
둘째 줄에는 맵의 가로길이 X( 1 ~ 100 ), 세로길이 Y( 1 ~ 100 )가 입력이 된다.
그 이후로는 맵의 데이터가 들어온다.

Output

지뢰 주변에 있는 숫자와 지뢰, 아무런 영향이 없다면 빈공간을 출력하자

Sample Input Copy

3
67 8
.........*..............*...*....*...*....*...........*.........*..
.....*...**..............*....................*...**............*..
.......*............*....*.....*..........*.....*................*.
......*......................*...*...*......*.*................*...
..*.*..................*...............*.*...........*.*.....*.....
...........*...**..*.....*...*...*................................*
.*.................*........*.............................*........
..**.......**.......*.............*.....*..**.*.....*............*.
24 40
........................
.....*.........*........
........*.*........*..*.
.....................*..
...*...*.......*....*...
.........*.*............
...*.......*............
........*.*.*...........
............*.......**..
...*..*...........*.....
...*....................
........................
.......*...*.......*..*.
.*.........*............
.*...*.........*.....*..
..*.*..............*...*
......*....**...........
.....................*..
........................
..*........*............
....*...................
.....*.*................
..*..........*...*......
*....*...**.............
..............*.........
.................*......
................*...**..
.......*................
...................*..*.
..*......*..............
...*....................
*.....................*.
.......*..*.*.....*.....
........**...*..........
........................
....*...........*.......
.**..............**.....
.......................*
.....*....*.............
........*...*...........
32 22
................................
*.....**....*........*.....*....
*............*...*.....*........
................*.........*.....
..........*.....*.**.........*..
.....................*..*.......
.....*..............*.......*..*
....*...*....***.....*..........
................................
.**........*..*....*....*..*....
............*.................**
.......*......*..*..............
...*............*...............
*..*..........................*.
.........................*......
.....*.*..........*...**........
...*....*...........**......*...
.........................**.....
...*............**.........*....
..*..........*...*...........*..
...*.*..*.*.*...................
..*..........*..*...............

Sample Output Copy

....111.2*31...........1*211*1..1*1.1*1..1*1.111.12211*1.......2*2.
....1*213**1.......111.13*211111211.111..222.1*212**1111.......2*31
....123*2221.......1*1..2*2.112*211.111..1*21323*2221.........123*1
.11212*21..........11111211.1*212*1.1*212222*2*211..11211...112*211
.1*2*211..111.1221111.1*211.222.222.112*2*111211....1*2*1...1*21111
122211....1*1.1**12*2.112*112*1.1*1...11211.........11211111111..1*
1*321.....233112212*31..1111*21.1221...111122211...111...1*1....122
12**1.....1**1....12*1.....111...1*1...1*11**2*1...1*1...111....1*1
....111.......111.......
....1*111211..1*1.111111
....1111*2*1..111.1*22*1
..111.122211..111.123*21
..1*1.1*21211.1*1..1*21.
..222.112*3*2.111..111..
..1*1..1234*31..........
..111..1*2*4*2.....1221.
..1111121213*2...112**1.
..2*21*1...111...1*2221.
..2*2111.........111....
..111.111.111.....111111
111...1*1.2*2.....1*11*1
2*2.11211.2*2.111.112221
2*322*1...111.1*1.112*21
12*2*321..1221111.1*212*
.11212*1..1**1....112121
.....111..1221......1*1.
.111......111.......111.
.1*211....1*1...........
.112*2211.111...........
.1122*2*1...111.111.....
12*1223122211*1.1*1.....
*2111*1.1**11221111.....
11..111.1221.1*1111.....
.............1122*11221.
......111......1*211**1.
......1*1......111123321
.111..11211.......1*11*1
.1*21...1*1.......111111
122*1...111..........111
*1111.11111211...111.1*1
11....1*33*2*21..1*1.111
......12**222*1..111....
...111.1221.111111......
1222*1.........1*321....
1**211.........12**1..11
1221111..111....1221..1*
....1*1112*211........11
....1111*212*1..........
11...1221..111......111...111...
*2...1**1..1*21.111.1*211.1*1...
*2...1221..12*112*1.112*11221...
11.......1111112*4321.1111*1111.
.........1*1...2*3**211112111*1.
....111..111...112233*11*1.12221
...12*1111..12321..1*32111.1*11*
...1*211*1..1***1..12*1....11111
122211.1111123431.11211111111...
1**1......1*22*1..1*1..1*11*1122
1221..111.12*32211211..1111111**
..111.1*1..112*22*1..........122
112*2.111....112*21..........111
*12*2..........111......111..1*1
111121211........111.1222*1..111
..112*2*21.......1*223**211111..
..1*2122*1.......112**322222*1..
..222..111.....12211221.1**321..
.12*1.......1111**2.....123*211.
.1*3311112122*113*2.......112*1.
.23*2*11*2*2*321221.........111.
.1*2211112122*11*1..............

HINT

샘플 테스트 케이스를 만드는게 제일 어렵다.