Preparing NOJ

Mine sweeping

1000ms 32768K

Description:

I think most of you are using system named of xp or vista or win7.And these system is consist of a famous game what is mine sweeping.You must have played it before.If you not,just look the game rules followed.

There are N*N grids on the map which contains some mines , and if you touch that ,you lose the game.If a position not containing a mine is touched, an integer K (0 < =K <= 8) appears indicating that there are K mines in the eight adjacent positions. If K = 0, the eight adjacent positions will be touched automatically, new numbers will appear and this process is repeated until no new number is 0. Your task is to mark the mines' positions without touching them.

Now, given the distribution of the mines, output the numbers appearing after the player's first touch.

Input:

The first line of each case is two numbers N (1 <= N <= 100) .Then there will be a map contain N*N grids.The map is just contain O and X.'X' stands for a mine, 'O' stand for it is safe with nothing. You can assume there is at most one mine in one position. The last line of each case is two numbers X and Y(0<=X<N,0<=Y<N, indicating the position of the player's first touch.

Output:

If the player touches the mine, just output "it is a beiju!".

If the player doesn't touch the mine, output the numbers appearing after the touch. If a position is touched by the player or by the computer automatically, output the number. If a position is not touched, output a dot '.'.

Output a blank line after each test case.

Sample Input:

5OOOOOOXXXOOOOOOOXXXOOOOOO1 15OOOOOOXXXOOOOOOOXXXOOOOOO0 0

Sample Output:

it is a beiju!1........................

Note:

Info

Provider NOJ

Code NOJ1149

Tags

Submitted 2

Passed 0

AC Rate 0%

Date 04/20/2019 10:03:10

Related

Nothing Yet