杭电-2579Dating with girls(2)(bfs+三维标记)

实现端到端加密的WebRTC视频会议终端 需要注意的是,上述示例代码中没有涉及到具体的加密算法和密钥交换过程,而是通过WebRTC API自动处理了加密和密钥交换的细节。然后,我们通过信令服务器将本地SDP发送给对方,并接收对方的SDP。最后,我们将对方的SDP设置为远程描述,并将最终的连接建立起来。最后,我们将对方的SDP设置为远程描述,并建立最终的连接。在本文中,我们将探讨如何使用WebRTC构建一个加密的视频会议终端,并提供相应的源代码。在本文中,我们将探讨如何使用WebRTC构建一个加密的视频会议终端,并提供相应的源代码。 阅读详情

Dating with girls(2)

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2676    Accepted Submission(s): 749


Problem Description
If you have solved the problem Dating with girls(1).I think you can solve this problem too.This problem is also about dating with girls. Now you are in a maze and the girl you want to date with is also in the maze.If you can find the girl, then you can date with the girl.Else the girl will date with other boys. What a pity!
The Maze is very strange. There are many stones in the maze. The stone will disappear at time t if t is a multiple of k(2<= k <= 10), on the other time , stones will be still there.
There are only ‘.’ or ‘#’, ’Y’, ’G’ on the map of the maze. ’.’ indicates the blank which you can move on, ‘#’ indicates stones. ’Y’ indicates the your location. ‘G’ indicates the girl's location . There is only one ‘Y’ and one ‘G’. Every seconds you can move left, right, up or down.
 

Input
The first line contain an integer T. Then T cases followed. Each case begins with three integers r and c (1 <= r , c <= 100), and k(2 <=k <= 10).
The next r line is the map’s description.
 

Output
For each cases, if you can find the girl, output the least time in seconds, else output "Please give me another chance!".
 

Sample Input
1 6 6 2 ...Y.. ...#.. .#.... ...#.. ...#.. ..#G#.
 

Sample Output
7
 


这个题就是一个普通的bfs,但是要注意一点,在一定的时刻,障碍物是会消失的,这样一来,我们有些点可以走多次,每次取余k值不同是就是不同的状态,这时候,是可以重复走的,所以要用到三维数组记录!



#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int m,n,k,bx,by,ex,ey;
char  map[110][110];
int vis[110][110][11],mov[4][2]={0,1,0,-1,-1,0,1,0};
struct node{
	int x,y,step;
}ta,tb;
queue<node>q;
bool can(node x,node y)
{
	if((x.step+1)%k==0&&y.x>=0&&y.x<m&&y.y>=0&&y.y<n&&!vis[y.x][y.y][(x.step+1)%k])
	return true;
	
	if(y.x>=0&&y.y>=0&&y.x<m&&y.y<n&&!vis[y.x][y.y][(x.step+1)%k]&&map[y.x][y.y]!='#')
	return true;
	
	return false;
}
int bfs(int x,int y)
{
	int i;
	while(!q.empty())
	q.pop();
	ta.x=x;
	ta.y=y;
	ta.step=0;
	q.push(ta);
	while(!q.empty())
	{
		ta=q.front();
		q.pop();
		if(ta.x==ex&&ta.y==ey)
		return ta.step;
		for(i=0;i<4;i++)
		{
			tb.x=ta.x+mov[i][0];
			tb.y=ta.y+mov[i][1];
			if(can(ta,tb))
			{
				vis[tb.x][tb.y][(ta.step+1)%k]=1;
				tb.step=ta.step+1;
				q.push(tb);
			}
		}
	}
	return -1;
}
int main()
{
	int N,i,j;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d%d%d",&m,&n,&k);
		for(i=0;i<m;i++)
		{
			scanf("%s",map[i]);
			for(j=0;j<n;j++)
			{
				if(map[i][j]=='Y')
				{
					bx=i;
					by=j;
				}
				if(map[i][j]=='G')
				{
					ex=i;
					ey=j;
				}
			}
		}
		memset(vis,0,sizeof(vis));
		vis[bx][by][0]=1;
		int t=bfs(bx,by);
		if(t==-1)
		printf("Please give me another chance!\n");
		else
		printf("%d\n",t);
	}
	return 0;
}


华为OD机试 - 荒岛求生 - 栈Stack(Python/JS/C/C++ 新系统 100分) 每一题都有详细的答题思路、详细的代码注释、3个测试用例、为什么这道题采用XX算法、XX算法的适用场景,发现新题目,随时更新,全天优快云在线答疑。 阅读详情

相关推荐

AI大模型驱动的智能座舱研发体系重构

AI大模型正重构智能座舱研发体系的核心逻辑,需以场景认知为起点、混合架构为支柱、AI原生生态为落脚点。未来,研发体系需持续融合认知科学、边缘计算与开放生态理论,推动座舱从“工具”进化为“伙伴”。

我的专栏 1915

HDU2579(BFS)

大意:由Y到G,遇到#如果步数是K的倍数则可以走,求最小步数。 分析:点可以重复走,对于每一点如果步数对k取余相同,则可视为同一状态,不入队。 代码: #include<iostream> #include<cstdio> #include<queue> #include<cstring> using namesp...

weixin_34419321的博客 165

Cisco Packet Tracert 无线路由器配置

Cisco Packet Tracert 无线路由器配置

yushan_caoyu的博客 2万+

HDU 2579 Dating with girls(2)(bfs+三维标记)

Dating with girls(2)Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4105    Accepted Submission(s): 1216Problem DescriptionIf you have solved th...

BBHHTT的博客 365

ISP Tuning实战指南:从基础到高级的色彩与亮度优化

本文详细介绍了ISP Tuning的基础概念与高级调优技术,包括黑电平校正(BLC)、自动白平衡(AWB)、色彩校正矩阵(CCM)和Gamma曲线调整等核心算法。通过实战案例和调试技巧,帮助工程师提升摄像头成像质量,解决高光过曝、暗部噪点等常见问题,适用于智能门铃、车载摄像头等多种场景。

weixin_30879169的博客 107

告别屏幕闪烁:手把手教你用示波器抓取并分析MIPI DSI信号(以RK平台为例)

本文详细介绍了如何利用示波器抓取并分析MIPI DSI信号,以解决LCD屏幕闪烁、花屏等问题。以RK平台为例,从工具准备、示波器参数配置到信号捕获与波形解读,提供了一套完整的调试方案,帮助硬件工程师快速定位和解决显示接口信号完整性问题。

weixin_33704591的博客 654

hdu 2579 Dating with girls(2)(BFS)

同一个点可以走多次,但是最多不能超过k次。在二维的基础上扩展一维,将二维的搜索转化为三维。 #include #include #include using namespace std; #define N 105 int vis[N][N][12],mark[N][N]; int n,m,k; int sx,sy,ex,ey; int dir[4][2]={{-1,0},{0,-1},{1

zizaimengzhongyue的专栏 604

【SAP报错】BK128&K5112

在ECC中使用CO1F进行Progressive confirmation时,依次遇到了如下的报错。

weixin_45228526的博客 781

HDOJ 2579 Dating with girls(2)(bfs)

 Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2694    Accepted Submission(s): 754 Problem Description If y

Chunzhen的博客 568

【matlab】使用alexnet进行特征提取

1.下载alexnet工具箱 在命令栏输入alexnet,若不报错说明已经安装,若出现错误按照提示去下载工具箱; 下载地址:https://ww2.mathworks.cn/matlabcentral/fileexchange/59133-deep-learning-toolbox-model-for-alexnet-network (1)需要先注册(十分简单),登陆,下载; (2)下载完成之后,...

jingjingliang1995的博客 5843

9.6华为OD机试真题 新系统 - 少儿爬山闯关积分游戏 (Java/Py/C/C++/Js/Go)

2026 华为OD机试真题9月6日华为OD上机新系统考试真题 100 分题型。

算法大师! 854

Dating with girls(2)【HDU - 2579 】

If you have solved the problem Dating with girls(1).I think you can solve this problem too.This problem is also about dating with girls. Now you are in a maze and the girl you want to date with is als...

Meant_To_Be的博客 319

使用Simulink来模拟多旋翼无人机在风扰动条件下的飞行情况,并分析其稳定性

本教程详细介绍了使用Simulink进行多旋翼无人机风扰动稳定性分析的完整流程。首先构建包含飞行器动力学模型、控制系统和环境模拟模块的系统框架,重点讲解简化动力学方程的实现方法。随后指导设计PID控制器来维持姿态稳定,并添加随机风扰动模型模拟环境干扰。通过设置输入信号和输出显示,最终实现对不同风速条件下无人机控制性能的评估。该实例为无人机控制系统设计提供了实用的仿真方法,强调利用MATLAB工具进行可视化分析和参数优化,以提高系统抗干扰能力和稳定性。

amy_mhd的博客 418

hdu 2579 Dating with girls(2) 【经典三维BFS】

Dating with girls(2)                                                           Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)                                  

Fighting! 2780

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

杭电2579--Dating with girls(2)(Bfs)

Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2601Accepted Submission(s): 723 Problem Description If you ha...

dixi7825的博客 160

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

杭电2579Dating with girls(2)

Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2659    Accepted Submission(s): 744 Problem Description If you

hpuzsk的博客 540

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

HDU 杭电2579 Dating with girls(2) 【BFS】

http://acm.hdu.edu.cn/showproblem.php?pid=2579 Problem Description If you have solved the problem Dating with girls(1).I think you can solve this problem too.This problem is also about d

Determined&Diligent的专栏 455

ACM算法模板全家桶:构建高效可复用的竞赛代码体系

在编程竞赛中,算法模板是提高解题效率的关键工具。掌握数据结构、图论等核心算法原理,能够帮助开发者快速构建可靠代码。通过统一编码规范、边界测试与代码复用,模板库能显著降低临场调试风险。从ACM训练到工程实践,一套经过验证的模板体系可应用于各类算法场景。线段树、Dijkstra、Dinic等高频模块的封装与测试,配合对拍验证、评测系统适配,能够让模板真正成为稳定输出的后盾。本文以整理算法全家桶的完整思路为例,分享如何系统化沉淀知识、规范代码风格,并在真实竞赛中发挥实际价值。

weixin_33843947的博客 381

hdu 2579 Dating with girls(2)【BFS+全文翻译】

Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2821    Accepted Submission(s): 791 Problem Description If you

mengxiang000000 1113

杭电2579-Dating with girls(2) (非常清晰易懂的代码)

Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1476    Accepted Submission(s): 419 Problem Description If you h

ecjtu_acm_菜鸟—鱼尾尾 1099

杭电1018-Big Number(大数)

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 31165    Accepted Submission(s): 14464 Problem Description In ma

Eric_keke的专栏 2126

杭电1242-Rescue(bfs+优先队列||队列)

Rescue Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 21824    Accepted Submission(s): 7776 Problem Description Angel was ca

Eric_keke的专栏 1581

杭电1097-A hard puzzle(快速幂)

A hard puzzle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 35177    Accepted Submission(s): 12627 Problem Description lcy give

Eric_keke的专栏 1572

杭电1000- A+B Problem

A + B Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 499575    Accepted Submission(s): 158358 Problem Description Calc

Eric_keke的专栏 1485

杭电-1034Candy Sharing Game(模拟)

Candy Sharing Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4434    Accepted Submission(s): 2705 Problem Description A numbe

Eric_keke的专栏 1349

杭电find the safest road(最短路径,dijkstra,floyd)

find the safest road Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9502    Accepted Submission(s): 3360 Problem Description

Eric_keke的专栏 1201
上一篇: 杭电-1026Ignatius and the Princess I(BFS+记录路径)
下一篇: 杭电-2803The MAX
Eric_keke
博客等级 码龄12年 37粉丝 221原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值