1396 -- Mine of Alpc62
Time Limit :1000 MS Memory Limit :65536 KB
Accepts : 2 Submits : 38
User Accepts : 2 User Submits : 4
<Submit>   <Statistics>   <Discuss>

Description

Mine is a classical Windows game and ALPC62 loves it. But one day he saw zzningxp playing more skillfully than him. Through countless attempts, ALPC62 realized that zzningxp’s playing speed was so fast that there was only one way to beat him — designing an automatic cleaning off mines program.

In ALPC62’s opinion it is not complex:
STEP 1: Input one puzzle, judge which panes are mines, which are safe and which are ambiguous.
STEP 2: Control mouse to flag all the mines and open all the safe places. Then a new puzzle appears, report/output the new puzzle to STEP 1.
ALPC62 decides to complete STEP 2 by himself, and you receive the mission of programming STEP 1.
Notice that the total number of mines for you is not sure.

Input

The first line contains T (1<=T<=100), indicating the number of test cases.
Each test case contains 10 lines:
First 9 lines: each line contains 9 characters. The meanings of valid characters:
‘0’~’8’ : An opened pane and the number of mines in neighbor panes (8 direction)
‘.’   : An unopened pane
The last line is a blank line.

Output

For each case:
First line:"Case X:", X is the number of cases.

Next 9 lines: each line contains 9 characters.
The meanings of valid characters:
‘0’~’8’ : An opened pane, the number must be the same as the input
‘*’ : An unopened but a mine pane
‘`’ : An unopened but a safe pane
‘.’ : An unopened but a dubious pane
The last line of each case is a blank line.
 

Sample Input

2
.101...10
110124.20
000001.10
000001110
000000000
000011100
01122.210
12.....10
.......10
1........
.........
.........
.........
.........
.........
.........
.........
.........

Sample Output

Case 1:
*101***10
110124`20
000001*10
000001110
000000000
000011100
01122*210
12*`*`*10
..`...`10
Case 2:
1........
.........
.........
.........
.........
.........
.........
.........
.........

 

Source

Alpc NUDT campus contest 2009
<Submit>   <Statistics>   <Discuss>
 


Powered by Zhang Zhaoning PDL College of Computer
Since 2006.03.09 | 2007.11.22 | 2010.03.02 Copyright (r) 2006 - 2010 All Rights Reserved