60分,求助
查看原帖
60分,求助
1184377
Glocker楼主2024/6/17 17:25
#include "bits/stdc++.h"
using namespace std;
int dicx[4]={1,-1,0,0};
int dicy[4]={0,0,1,-1};
int maze[105][105];
int flag[105][105];
int n,m;
string jud="No";
void find(int x,int y){
	if(x==n-1&&y==m-1){
		jud="Yes";
		return ;
	}
	for(int i=0;i<4;i++){
		int tepx=x+dicx[i];
		int tepy=y+dicy[i];
		if(x>=0&&x<n&&y>=0&&y<m&&maze[tepx][tepy]==0&&flag[tepx][tepy]==0){
			flag[tepx][tepy]=1;
			find(tepx,tepy);
		}
	}
}
int main(){
	
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			char tep;
			cin>>tep;
			maze[n][m]=(tep=='#');
		}
	}
	flag[0][0]=1; 
	find(0,0);
	cout<<jud;
}
2024/6/17 17:25
加载中...