hdu 1072 Nightmare (广搜)

Cisco 路由器 打环测试教程 环 回测试是很常用的一种测试,通常用于检查和分析端口或线路问题。如下图所示,我们在设备端口上用命令loopback(某些端口上命令格式为 loopback diagnostic)使接口从内部将自己发送的信号转接到自己的接收端(如红线所示),通过检查数据发送和接收的情况来判断端口工作状态是否正常。如果 需要对端口进行完全的检测,可以使用符合标准的短跳线将端口收发短接构成环... 阅读详情

/*

题意: 2为起点,3为终点,开始时间为6,没走一步减1; 遇到4时重新计时,可重复走。

解题:就是普通的广搜,唯一不同的是路可重复走,将标记是否走过的mark数组,标记为走过一次加1,每一个位子最多可走8次即可。

*/


#include<iostream>
#include<queue>
using namespace std;
int n, m, s[10][10], mark[10][10], dir[4][2] = {1,0, 0,1, -1,0, 0,-1};
int flag, s_x, s_y, e_x, e_y;

struct node
{
	int x, y, step;
	int flag_step;
};

int judge(int x, int y)
{
	if(x>=0 && x<n && y>=0 && mark[x][y]<8 && s[x][y] != 0)
		return 1;
	else
		return 0;
}

int bfs()
{
	int i;
	queue<node>q;
	node cur, next;
	cur.x=s_x; cur.y=s_y; cur.step=0;
	cur.flag_step=0;
	q.push(cur);
	while(!q.empty())
	{
		cur = q.front();
		q.pop();
		if(cur.x==e_x && cur.y==e_y) return cur.step;
		if(cur.flag_step == 5) continue;
		for( i=0; i < 4; i++ )
		{
			next.x = cur.x + dir[i][0];
			next.y = cur.y + dir[i][1];
			if(judge(next.x, next.y))
			{
				mark[next.x][next.y] += 1;
				next.step = cur.step+1;
				next.flag_step = cur.flag_step+1;
				if(s[next.x][next.y] == 4)
					next.flag_step = 0;
				q.push(next);
			}
		}
	}
	return -1;
}

int main()
{
	int T;
	scanf("%d", &T);
	while(T--)
	{
		int i, j;
		scanf("%d%d", &n, &m);
		for( i=0; i < n; i++ )
			for(j=0; j < m;j++ )
			{
				scanf("%d", &s[i][j]);
				if(s[i][j] == 2)
					s_x=i, s_y=j;
				if(s[i][j] == 3)
					e_x=i, e_y=j;
			}
			
		memset(mark, 0, sizeof(mark));
		flag = 0;
		int ans = bfs();
		printf("%d\n", ans);
	}
	return 0;
}


ubuntu下编译qtwebengine ubuntu qtwebengine 阅读详情

相关推荐

2025 高效抓取雪球社区数据:自动化导出Excel与PDF全攻略

本文详细介绍了2025年高效自动化抓取雪球社区数据的完整方案。通过Python脚本,用户可自动抓取帖子列表数据并导出为结构化的Excel表格,同时批量将帖子内容保存为PDF文档,并支持合并与添加书签,极大提升投资研究和信息整理的效率。

weixin_29034963的博客 691

【并查集】POJ_1984_Navigation Nightmare

Navigation Nightmare Time Limit: 2000MS   Memory Limit: 30000K Total Submissions: 7036   Accepted: 2521 Case Time Limit: 1000MS Description Farmer John's pastoral ne

yiluuuuu的博客 357

Unity插件EasyToucu安卓平台的个人开发实例

在学习了NightmareShooter这款游戏开发案例之后,我打算把它发布到安卓平台,但是原来的案例的安卓平台的角色控制脚本并不满足我的需求,然后,我找到了EasyTouch这款插件。 一、创建按钮 首先,导入EasyTouch插件,然后,在Hierachy上右键点击EasyTouch Controls EasyTouch一共有几种按钮样式:分别是Joystick,D-Pa

wathp的博客 877

保姆级教程:在Ubuntu 20.04上从源码编译Apollo自动驾驶平台(含GPU环境配置)

本文提供了一份详细的Ubuntu 20.04上从源码编译Apollo自动驾驶平台的保姆级教程,包括GPU环境配置、Docker部署和编译构建等关键步骤。通过实战经验和避坑指南,帮助开发者高效完成Apollo平台的编译和验证,适用于自动驾驶技术研究和应用开发。

weixin_30876945的博客 406

【WireShark】WireShark windows平台编译 问题解决

最近工作中需要基于wireshark做二次开发,在windows平台构建过程中 遇到了找不到Glib库的问题,具体报错如下: Working in D:\WorkSpace\WIRESHARK\wiresharksource\wireshark-win64-libs Tag 2021-08-14 not found. Refreshing. Downloading https://anonsvn.wireshark.org/wireshark-win64-libs/tags/2021-08-14/pac

qq_35456540的博客 1545

hdu1072 Nightmare 广搜

题目链接~传送门 题目大意:

asdasd 613

Codex 自定义模型操作指南:CLI 与桌面客户端双端实操

检查版本 codex --version # 预期输出类似:codex-cli 0.133.0-alpha.1 # 如未安装 npm install -g @openai/codex假设你要接入DeepSeek,在# 临时设置(当前终端会话有效)export DEEPSEEK_API_KEY="sk-你的 DeepSeek API Key"# 永久设置(推荐,写入 shell 配置)

篮球界最会写bug的人;程序猿中打球最菜的人。 454

HDU 1072 Nightmare【广搜】

分析: 给一个地图,一个人从起点开始,身上有一个定时炸弹,时间为6,每走一步花费一个时间,走到标号为4 的点上时时间重置, 问从起点到终点最少需要经过多少步。 分析: 直接广搜,加上对状态的判重。。。 View Code #include<stdio.h> #include<string.h> struct node { int...

weixin_33744854的博客 91

166、电流环带宽测试

本文分享了电流环带宽测试的实战经验,揭示了常见误区:误将系统其他环节(如PWM、ADC、传感器)的延迟当作电流环性能。强调带宽测试需先断开速度/位置环,采用扫频法注入正弦信号,结合伯德图分析幅值与相位响应。关键点包括:控制频率步进为对数、确保采样时序精准、避免传感器带宽限制影响结果。文中指出“假带宽”现象(如鼓包、增益超0dB)多源于非线性或机械共振,建议遵循“先开环后闭环”“带宽非越高越好”“阶跃验证”三原则,并建立出厂基准曲线以支持后期故障诊断。

2401_88858637的博客 175

深入理解 Terraform 中的资源更新与管理

摘要:本文探讨Terraform处理AWS安全组名称变更时的行为。当修改不可变属性(如安全组名称)时,Terraform会创建新资源并删除旧资源。通过状态文件比对所需状态与实际状态,Terraform对不可变属性采用"先创建后删除"策略,对可变属性则直接更新。实例演示了修改安全组名称和关联EC2实例时的处理过程,强调理解资源属性可变性对基础设施管理的重要性。(149字)

2501_90323865的博客 471

HDU 1072 Nightmare(广搜BFS)

Problem Description Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb e...

loven0326的博客 208

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

hdu 1072 Nightmare (广搜)

// Time 0ms, Memory 356K#include #include #include using namespace std; int n,m,p[9][9],sx,sy,dx[]={0,1,0,-1},dy[]={1,0,-1,0}; struct point { int x,y,time,step; point(int x=0,int y=0,int time=

二十一画生的专栏 1250

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

hdu1072Nightmare(广搜)

题目链接:click~ 题目解析:

Y_Y 400

HDU 1072 Nightmare (广搜)

题目链接 Problem Description Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bo...

weixin_30916125的博客 105

HDU 1072 Nightmare(广搜)

由于可以回到原地,所以多种状态可以叠加,不处理容易超时。增加一个二维数组判断到该点时剩余时间的最大值,如果当前状态的剩余时间大于该值,则加入队列,否则舍弃。 #include #include #include #include using namespace std; const int maxn =10+5; int a[maxn][maxn]; int n,m,si,sj; boo

Learn as if you were to live forever 613

HDU 1072 Nightmare(广搜bfs)

Nightmare Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 14388 Accepted Submission(s): 7001 Problem Description Ignatius had a nightmare la...

雷银行的博客 326

hdu 1072 Nightmare(广搜(迷宫类题))

题意:给你一个迷宫地图你在迷宫里并携带一个定时炸弹,炸弹将在6秒后爆炸每次你只能上下左右走,且每步耗时一秒,地图里2代表你的初始位置,3代表迷宫的出口,1表示可以走的路,0表示墙,4表示定时炸弹时间重置装置(爆炸时间重新变为6秒),你到达出口或4位置炸弹剩余时间必须大于0秒,求走出迷宫的最短时间,走不出输出-1。 思路:用一个结构体来存地图上每个点对应的状态(坐标位置x,y,剩余时间:time,...

qq_41999763的博客 250

HDU1072 Nightmare(广搜BFS+优先队列)

题目: Nightmare Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10533    Accepted Submission(s): 5128 Problem Description Ignati

riba2534的博客 661

HDU1072_Nightmare_优先队列+广搜

题目大意: 地图中的五种元素:0代表墙 1代表空地 2代表人的起点 3代表出口 4代表炸弹的重启器 炸弹只有6秒的时间,地图中的任何地方都可以走多遍,如果遇到4,那么炸弹的时间被重置为6,要求算出人到达出口的最短时间。 解题思路: BFS+...

weixin_30502965的博客 85

HDU--杭电--1072--Nightmare--广搜--这种题目不是简单的标记了,应该是标记过还要能再访问

Nightmare Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5602    Accepted Submission(s): 2784 Problem Description Ignatius had a nig

浩爷地带,你的地盘听我的.... 1410

hdu1072 Nightmare C语言编写 广搜加队列 注意不要把所有走过的路封死 只封4的路 逃出后时间大于0

#include #define max 9 int map[max][max],n,m,xi,yi; int next[4][2]={1,0,0,1,-1,0,0,-1}; struct point { int x,y; int cost; //花费时

414

广搜习题

HDU1072 NightmareNightmareTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11091 Accepted Submission(s): 5401Problem Description Ignatius ha

moonlight的博客 346

HDU 1072 Nightmare

题目 hduoj1072 Nightmare Problem Description Ignatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb explodes. The initial exploding tim

wenrenfudi的博客 277

HDU【1072】Nightmare

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1072 分析 这道题目涉及到bfs+回溯,所以不能像一般的bfs将经过的点进行标记,因为题目中炸弹的爆炸时长为6,所以只需要将经过的4的点进行标记,其他已经走过的点也只是在4这个点上最多回溯6步。 #include<iostream> #include<cstdio> #incl...

yj8023xx的博客 275
上一篇: hdu 1026 Ignatius and the Princess I(广搜+优先队列)
下一篇: hdu 1180 诡异的楼梯(广搜+队列)
asure__cpp
博客等级 码龄14年 8粉丝 150原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值