60分,只有Yes的样例点过了,悬关
  • 板块B3625 迷宫寻路
  • 楼主wch666
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/10/6 14:57
  • 上次更新2023/11/2 15:15:34
查看原帖
60分,只有Yes的样例点过了,悬关
778382
wch666楼主2023/10/6 14:57
#include <bits/stdc++.h>
using namespace std;
int n,m;
char mapp[505][505];
int dl[250005][2];
const int qx[4]={0,0,1,-1};
const int qy[4]={-1,1,0,0};
void BFSS()
{
	int head=0,tail=1,tx,ty;
	mapp[0][0]=1;
	dl[tail][0]=0;
	dl[tail][1]=0;
	while(head != tail)
	{
		head++;
		tx=dl[head][0];
		ty=dl[head][1];
		int newx,newy;
		for(int i=0; i<4; i++)
		{
			newx=tx+qx[i];
			newy=ty+qy[i];
			if(newx < 0 || newx > n+1 || newy < 0 || newy > m+1)
				continue;
			if(mapp[newx][newy] == '*')
				continue;
			mapp[newx][newy]='*';
			tail++;
			dl[tail][0]=newx;
			dl[tail][1]=newy;
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1; i<=n; i++)
		for(int j=1; j<=m; j++)
			cin>>mapp[i][j];
	BFSS();
	if(mapp[n][m] == '*')
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}
2023/10/6 14:57
加载中...