VPL2_BC  Peter Quest
Is Peter’s birthday! And his friends are preparing a big party, however, Peter is obsessed with a variation of the famous game Minesweeper, moreover, Peter hates losing, so if any of you or your friends can beat him in the game, he will get angry and will attend the party that everyone is organizing for him.
This new mode of Minesweeper consists in building the gameboard given the mines, so, if the matrix has size of (2x2) and there is a mine in the position (0,0) of the matrix, the resultant gameboard will be *1 11 Your task is to beat Peter and celebrate his birthday before its too late! Please have in consideration that:
• The cell (i,j) where there is a mine will be denoted as ’*’
• The cell (i,j) where there is no mine will be denoted as ’’
• The cell (i,j) where there is N mines adjacent to it, will be denoted as a number from 1 to 8 (depending on the number of adjacencies)
Input
The first line contains an integer T , which specifies the number of test cases. Then, will follow the descriptions of T test cases.
For each test case, you will have a line with three numbers N , M , K, denoting, respectively, the size of the matrix, formed by N columns and M rows, and K mines. Then, K lines will follow, each containing two numbers Ki and Kj denoting the position where the mine is in the board.
Output
For each test case you should print the string "Scenario #i:" where i represents the test case you are analyzing (starting from 1), then, in the next line, you shall print the gameboard as specified.
INPUT 
OUTPUT 
3 3 2 2 0 0 1 1 3 3 3 0 0 1 1 2 2 8 8 10 0 1 5 0 2 5 4 5 2 6 5 6 6 6 5 7 6 7 7 7 
Scenario #1: *2 2* 11 Scenario #2: *21 2*2 12* Scenario #3: 1*1 1111221 1**1 2331 111*32 *113** 112** 13* 
Constraints  Subtask 1 (10%)
• 1 ≤ T ≤ 10
• 1 ≤ N ,M ≤ 8
• 1 ≤ K ≤ min(8,N *M )
Constraints  Subtask 2 (20%)
• 1 ≤ T ≤ 10
• 1 ≤ N ,M ≤ 128
• 1 ≤ K ≤ min(128,N *M )
Constraints  Subtask 3 (30%)
• 1 ≤ T ≤ 10
• 1 ≤ N ,M ≤ 1024
• 1 ≤ K ≤ min(1024,N *M )
Constraints  Subtask 4 (40%)
• 1 ≤ T ≤ 10
• 1 ≤ N ,M ≤ 6144
• 1 ≤ K ≤ min(100000,N *M )
hide comments
ankit kumar:
20150612 14:16:32
wow.. felt good 

anurag garg:
20131218 08:46:16
nice problem...good implementation Last edit: 20131218 08:46:43 

Ouditchya Sinha:
20130815 12:33:55
Nice problem, another fastest solution for me. :) 

Garg Ankit:
20130729 20:50:20
@Mostafa


Mostafa 36a2:
20130728 18:00:37
@Garg Ankit


Garg Ankit:
20130728 11:56:29
Any tricky test case?


Mostafa 36a2:
20130728 09:46:03
OUCH , just one letter in my code cost me 10 WA :D 

biQar:
20130715 07:56:46
I have doubt about the Time Limit for Java solutions. Problemsetter should check that. I am waiting for the response.


SWOOSH!!!:
20130713 06:23:44
Last edit: 20130713 13:56:12 

BLANKRK:
20130708 17:41:16
wow!! got AC in fst attmpt.... :D 
Added by:  Venezuelan Programming League 
Date:  20130629 
Time limit:  5s10s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 