Problem C: Mine Sweeping Game (华中农业预赛)
2016-05-14 16:38
281 查看
Problem C: Mine Sweeping Game
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 237 Solved: 127
[Submit][Status][Web
Board]
Description
As everyone knows, Mine Sweeping is a very famous computer game. When Diao Fei was young, he also liked to play this game very much. A sample of situation when win the game is like this below:In a situation of winning this game, there are three kinds of grid:
·number grid:the grid has a number in it.Like
·blank grid:the grid has nothing in it. Like
·mine grid:the grid has a mine in it. Like
The game’s rule is that, if a grid is a number grid and it has an number x in it, the eight grids (up, down, left, right, up-left, up-right, down-left, down-right, if exists) which around it should have excatly
x mine grids in total. If a grid is a blank grid, then any grid around it should not be a mine grid.
Now the problem is, in a situation of winning this game, giving all of the mine grids, your task is to determine what kind the remain grids are.
Input
The first line contains an integer T, indicating the total number of test cases.In each test case, the first line is three integers N, M,
K(
,
) indicating the game size is
N rows (numbered from 1 to N) and M columns (numbered from
1 to M), and there are K mines in total. Then K lines follow, each line contains two integersx,
y(
,
) indicating the grid in xth row and
yth column is a mine grid. You can assume that there are not any two mine grids in the same position.
Output
For each test case, output N lines, each line contain M characters, the jth character in theith line indicates the grid in the ith row and the jth column. If the grid is a number grid, output the number in the grid. If the grid is a blank grid, output the character ‘.’ (without quotes). If the grid is a mine grid, output
the character ‘M’ (without quotes). Notice that after each test case, you should output a blank line at the end.
Sample Input
2 9 9 10 1 1 2 1 2 6 3 3 5 9 6 3 6 8 6 9 7 6 8 2 5 5 1 3 3
Sample Output
M2..111.. M3111M1.. 12M1111.. .111...11 .111..13M .1M1112MM 12211M222 1M1.111.. 111...... ..... .111. .1M1. .111. .....
HINT
水题:不BB了,这都写半天,格式还出错~~菜啊~?
相关文章推荐
- js图片转base64编码压缩上传
- 虚拟地址,虚拟地址空间, 交换分区
- 系统参数的设计,通用方法提取,页面处理map字符串并显示系统参数(增强版)
- 线程
- Android中操作数据的集中方式---文件,SQLite,ContentProvider
- 常用效果集绵
- Ubuntu on Windows 10工作方式全解析
- PHP5升级到PHP7注意点(windows环境)
- 纯手工编写可执行程序
- LINUX 运维命令
- 练习: C#---函数(100以内7有关的数、99乘法表、100以内奇数和、硬币组合)
- 在WebLogic新建针对Oracle数据库的JNDI数据源
- 1003 Problem C
- UbuntuBSD 官方网站正式上线
- 抽象类
- Debug和Release区别
- 《 常见算法与数据结构》符号表ST(2)——初等实现分析和有序符号表
- 两招让你成为牛X的T型人才
- 编写XML文件
- 事务-程序员的必经之路