poj 2612 Mine Sweeper

mine-sweeper 扫雷车 立即下载

Mine Sweeper
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 6429 Accepted: 2500

Description

The game Minesweeper is played on an n by n grid. In this grid are hidden m mines, each at a distinct grid location. The player repeatedly touches grid positions. If a position with a mine is touched, the mine explodes and the player loses. If a positon not containing a mine is touched, an integer between 0 and 8 appears denoting the number of adjacent or diagonally adjacent grid positions that contain a mine. A sequence of moves in a partially played game is illustrated below. 
 
Here, n is 8, m is 10, blank squares represent the integer 0, raised squares represent unplayed positions, and the figures resembling asterisks represent mines. The leftmost image represents the partially played game. From the first image to the second, the player has played two moves, each time choosing a safe grid position. From the second image to the third, the player is not so lucky; he chooses a position with a mine and therefore loses. The player wins if he continues to make safe moves until only m unplayed positions remain; these must necessarily contain the mines. 

Your job is to read the information for a partially played game and to print the corresponding board. 

Input

The first line of input contains a single postitive integer n <= 10. The next n lines represent the positions of the mines. Each line represents the contents of a row using n characters: a period indicates an unmined positon while an asterisk indicates a mined position. The next n lines are each n characters long: touched positions are denoted by an x, and untouched positions by a period. The sample input corresponds to the middle figure above.

Output

Your output should represent the board, with each position filled in appropriately. Positions that have been touched and do not contain a mine should contain an integer between 0 and 8. If a mine has been touched, all positions with a mine should contain an asterisk. All other positions should contain a period.

Sample Input

8
...**..*
......*.
....*...
........
........
.....*..
...**.*.
.....*..
xxx.....
xxxx....
xxxx....
xxxxx...
xxxxx...
xxxxx...
xxx.....
xxxxx...

Sample Output

001.....
0013....
0001....
00011...
00001...
00123...
001.....
00123...

注意:如果踩到地雷,要把所有地雷表示出来;

#include <iostream>
using namespace std;
#define MAX 12
int n;
char map[MAX][MAX],ans[MAX][MAX];
int count(int i,int j,int n){
	int ans=0;
	if (map[i-1][j-1]=='*' && i-1>=0 && j-1>=0)
		ans++;
	if (map[i-1][j]=='*' && i-1>=0)
		ans++;
	if (map[i-1][j+1]=='*' && i-1>=0 && j+1<n)
		ans++;

	if (map[i][j-1]=='*' && j-1>=0)
		ans++;	
	if (map[i][j]=='*')
		ans++;
	if (map[i][j+1]=='*' && j+1<n)
		ans++;

	if (map[i+1][j-1]=='*' && i+1<n && j-1>=0)
		ans++;
	if (map[i+1][j]=='*' && i+1<n)
		ans++;
	if (map[i+1][j+1]=='*' && i+1<n && j+1<n)
		ans++;
	return ans;
}
int main(){
	
	while (cin>>n){
		for (int i=0;i<n;i++)
			for (int j=0;j<n;j++)
				cin>>map[i][j];
		int flag=0;
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++){
				cin>>ans[i][j];
				if (map[i][j]=='*' && ans[i][j]=='x')
					flag=1;
				if (ans[i][j]=='x'){
					int k=count(i,j,n);
					ans[i][j]=k+'0';
				}
			}
		}
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++){
				if (flag==1 && map[i][j]=='*')
					cout<<map[i][j];
				else
					cout<<ans[i][j];
			}
			cout<<endl;
		}
	}
	return 0;
}



单细胞转录组上游分析完整流程(超详细) 本指南详细介绍单细胞转录组数据分析流程,从10xGenomics平台数据出发,使用CellRanger工具完成从原始FASTQ文件到基因表达矩阵的全过程。内容涵盖:1) 环境准备与参考基因组获取;2) 测试数据下载;3) 数据质量检测方法;4) CellRanger核心流程详解;5) 结果解读;6) 下游分析衔接。同时提供开源替代方案kallisto|bustools的使用说明,并解答常见问题。适合单细胞转录组分析初学者快速掌握标准分析流程。 阅读详情

相关推荐

避坑指南:Xilinx SelectIO IP核官方例程里那些容易忽略的细节(复位、时钟与数据回环)

本文深入解析Xilinx SelectIO IP核设计中复位策略、时钟域交互和数据回环验证三大关键领域的实战避坑技巧。针对官方例程中易被忽视的细节,如复位同步链深度、时钟相位约束和数据对齐机制,提供经过项目验证的优化方案,帮助工程师节省80%以上的调试时间。特别适用于FPGA开发中高速接口设计场景。

weixin_42561476的博客 447

poj-2612

解题思路:题目其实不难,但是处理的时候技巧性很强,在输入过程中利用标志flag直接判断有无触发地雷,直接省去了两个for循环。多次使用a?b:c的结构,省去了大量不必要的判断语句,其实解题时还要注意的就是,我们应该把所有的点周围的地雷数利用二重循环存储到数组中,而不应该在判断的时候在临时计算。此题给我最大的启发就是,提前将一些要计算的算好存起来,不要一边判断一边计算,效率极低还易出错。#inclu

acm_JL的博客 950

【实战技巧】matplotlib中文标签显示问题的3种高效解决方案

本文详细介绍了解决matplotlib中文标签显示问题的3种高效方法,包括修改字体设置、临时指定字体和修改后端配置。针对不同操作系统和环境提供了实用技巧,帮助开发者快速解决中文显示为方框的常见问题,提升数据可视化效果。

weixin_30855099的博客 170

POJ 2612

Mine Sweeper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7278   Accepted: 2808 Description The game Minesweeper is played on an n by n grid. In this grid are hidden ...

一只菜鸟夹 533

【GAMES101】现代计算机图形学入门 资料整理

课程网址 课程主页 包括ppt 课程PPT和视频 一篇搞定!GAMES101现代计算机图形学入门(全) 作业链接地址 作业论坛 GAMES101课程环境搭建(Win10+VSCode) 计算机图形学笔记 虎书pdf 提取:n2rx 【必须】:高等数学(微积分、线性代数)、算法、数据结构 【非必须】:信号处理、数值分析、大学物理(光学) 在线公式编辑器 一定要做作业,如果个人要配置环境的话应该是配置opencv,eigen这两个核心库就行了,目前觉得最核心的一个作业是作业3,实现着色器和渲染管线,做完一遍

ysh的博客 2683

整理并记录几种运算放大器

运算放大器是一种十分常见的电子元器件,最近我在学习运放,以前在学校没有好好的学习,今天在B站看了唐老师讲运算放大器-唐老师讲电赛系列视频教程,记录下所学的,纯当是自己的笔记 学习运放,有两个重要的概念及重要的计算法宝,虚短vp=vn;和虚断ip=in 1反向比例运算电路 Rf可以大于、小于或等于R,起到放大、跟随、衰减输入的作用; 平衡电阻没有太高的精度要求,可加可不加; 有些运放内部集成了补偿电路,就不需要使用平衡电阻,加了反而增大误差,如OPA227 2.同向比例运放电路 .

qq_36823004的博客 6364

poj 2612 扫雷

题目大意:给两个地图,一个是地雷图,一个是玩家游戏图 原题连接:poj 2612 思路: 首先判断 是否踩到雷 如果踩到mc=’*’ 否则mc=’.’ 然后遍历 如果 touch[i][j]=='x'&amp;&amp;Map[i][j]=='.'则看一下[i][j]周围几个雷 否则 touch[i][j]=='.'||Map[i][j]=='*'如果[i][j]是雷 则mc,否则 ‘.’ 心...

菜鸟的博客 373

【推荐100个unity插件】Animator 的替代品?—— Animancer Pro插件的使用介绍

Animancer与Unity Animator对比及使用指南 摘要: 本文对比了Animancer与Unity官方Animator的核心差异,分析了Animancer的优势特点。Animancer采用代码驱动模式,相比Animator的状态机系统更灵活高效,支持实时调试、动态混合和深度逻辑集成。文章详细介绍了Animancer的快速使用方法,包括动画播放、切换和触发机制,并区分了免费版与专业版的功能差异。适合需要高效动画开发、复杂交互逻辑的中小项目,为开发者提供了一种现代化的动画解决方案。

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 2434

POJ 2612 Mine Sweeper 模拟

Mine Sweeper Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6234   Accepted: 2446 Description The game Minesweeper is played on an n by n grid. In this grid

kdwycz的刷题空间 856

Axure RP9.0 教程:左侧菜单列表导航 ( 点击父级菜单,子菜单自动收缩或展开)【响应式的菜单导航】

1. 设置目标原件时,选择切换,这样就可以实现,当原件展示时,点击自动隐藏,隐藏时自动显示; 2. 展开/收起原件(推动/拉动原件)设置为方向**向下**

专注于计算机研发知识和资讯分享 1378

【人工智能】从零开始玩转龙虾(Openclaw):本地与云端(火山Arkcloud)部署全指南

龙虾(Openclaw)是一款海外智能体操作系统(agent operating system),可通过飞书机器人实现自动化办公、信息抓取、任务协作等功能。它支持本地部署和云端部署两种方式,适配MacOS和Windows系统(,建议优先使用MacOS)。sudo。

奶爸的编程之路,也就一周冷个三天 947

fjnu 1579 Mine Sweeper

DescriptionThe game Minesweeper is played on an n by n grid. In this grid are hidden m mines, each at a distinct grid location. The player repeatedly touches grid positions. If a position with a m

异リ度ュ空ウ間(镜像站) 911

web逆向伪瑞数案例:宝武资源有限公司(面向对象补环境)

声明:该文章为学习使用,严禁用于商业用途和非法用途,违者后果自负,由此产生的一切后果均与作者无关前言:之所以称伪瑞数案例,是因为该网站,无论是补环境的方法、还是环境都和瑞数差不多,因为第一次遇到这种网站,不确定是不是瑞数的一种,所以这里称伪瑞数,有知道的道友,可以评论区评论下,共同进步。,这里就不做多介绍了1.瑞数中的是t​s,而该网站是_ss。2.外链js代码不能格式化,否则补环境时会遇到一个超过数组长度的报错。3.call执行后的虚拟文件中有超多的debugger。

老衲爱洗头的博客 2534

poj 2612 Mine Sweeper

poj  2612  Mine Sweeper               题目链接:http://poj.org/problem?id=2612 模拟水 题目大意:扫雷情境模拟,给出雷区图,给出试探区域,按规则输出。 题目分析:暴搜水题一道,重点在题意理解,if(踩到了雷)输出所有雷的位置,和试探区域情况(仅);else 输出试探区域情况。 code: #include #includ

slicer的技术交流栈 978

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

POJ 2612 Mine Sweeper 扫雷游戏

原题 http://poj.org/problem?id=2612 题目大意: 扫雷的玩法就是翻数寻雷,翻出来的数是1代表周围的八个格子有1个雷,2代表有2个,等等。 逆向思维的结果就是每个雷周围有8个1,当两个雷有相邻的时候,数字可以叠加。 简单的遍历就可以求出结果。不太清楚的可以去玩几把。 注意:点到雷的时候所有雷都是会显示的。代码如下:#include <iostream> #in

ShineRoyal 625

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

POJ 2612 Mine Sweeper G++

#include //谢谢博友翻译 using namespace std; int main() { int NUM; cin>>NUM; char a[NUM][NUM]; char b[NUM][NUM]; char jg[NUM][NUM]; for(int i=0;i<NUM;i++) { for(int j=0;j<NUM;j++) { cin>>a[i

woniupengpeng的专栏 335

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

poj 2612 Mine Sweeper 简单模拟

//poj 2612 //sep9 #include using namespace std; int n; int cnt[16][16]; char mine[16][16]; char touch[16][16]; int dx[8]={-1,0,1,-1,1,-1,0,1}; int dy[8]={1,1,1,0,0,-1,-1,-1}; int main() { memset(cnt

sepNINE的专栏 901

poj2612Mine Sweeper

很简单的模拟题目,但在队内赛的时候一直WA了10发。。。我ca 题目没看懂,也不算,就是我以为摸到地雷他会标星(*) ,但其实还是(x),T_T 1 #include <cstdio> 2 #include <iostream> 3 #include <cstring> 4 using namespace std; 5 ...

weixin_33744141的博客 119

POJ 2612/ZOJ 1862 Mine Sweeper

题目链接: http://poj.org/problem?id=2612 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1862 题目描述: 扫雷游戏是在n×n的网格内进行的,其中藏有m颗地雷,这些地雷分布在不同的位置。游戏者不停地点开网格中的位置。如果点开了地雷,则引爆地雷,游戏失败。如果点开了没有地

赞的心路历程 941

模拟->YY POJ 2612 Mine Sweeper

Mine Sweeper Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2612 Description The game Minesweeper is played on an n by n grid. In

Fate_O的专栏 910

POJ 2612 Mine Sweeper(水~)

Description 扫雷,给出一张n*n的图,’‘表示地雷,’.’表示没有雷,现在对这张图进行一些操作,’X’表示操作,’.’表示没有操作,如果在操作中没有踩到雷,则在操作点处输出该操作点周围的地雷个数,在无操作点处输出’.’,如果踩到雷了,在上面的基础上将所有无操作且出现雷的地方输出’’ Input 第一行为一整数n表示地图大小,之后为一n*n矩阵表示该地图,最后一n*n矩阵表示操作

ZSQ 685

POJ2612 ZOJ1862 UVA10279 Mine Sweeper【Ad Hoc+模拟】

Mine Sweeper Time Limit:1000MS Memory Limit:65536K Total Submissions:7153 Accepted:2769 Description The game Minesweeper is played on an n by n grid. In this grid are hidden ...

海岛Blog 1171
上一篇: poj 2601 Simple calculations
下一篇: poj 2243 Knight Moves
JinbaoSite0144
博客等级 码龄12年 231粉丝 157原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值