【YBTOJ】逃离噩梦

在这里插入图片描述

思路:

这道题要从男孩和女孩同时开始bfs,如果男孩走过女孩走过的点,那么就输出时间,女孩同理
当前格子能不能走只需要判断鬼的哈密顿距离是否能到达就行了
详见代码(其实就一个注释)

c o d e code code

#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<cmath>
using namespace std;
int t;

struct node
{
   
	int x, y, s;
}; 

int n, m, g1x, g1y, g2x, g2y, flag;

char a[1000][1000];

queue<node> f, q;

int v[1000][1000];

int dx[4]={
   0, 1, 0, -1};
int dy[4]={
   1, 0, -1, 0};
inline int read() {
   
	int x=0, f=1; 
	char s=getchar();
	while (s<'0'||s>'9')
	{
    
		if(s=='-')
			f=-f; 
		s=getchar(); 
	}
	while(s>='0'&&s<='9')
	{
   
		x=x*10+s-'0';
		s=getchar();
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值