AC4个点
查看原帖
AC4个点
1268529
jiangbaolin楼主2024/5/29 17:38
#include<bits/stdc++.h>
using namespace std;
long long a[10001][10001],k=1,n,m,s,plasx[4]={0,1,0,-1},plasy[4]={1,0,-1,0};
bool tf=false;
char c;
void go(int x,int y){
	if(tf){
		return;
	}
	if(x==n&&y==m){
		tf=true;
		return;
	}
	else{
		for(int i=0;i<=3;i++){
			if(a[x+plasx[i]][y+plasy[i]]==1){
				a[x][y]=0;
				go(x+plasx[i],y+plasy[i]);
				a[x][y]=1;
			}
		}
	}
}
int main(){
	cin >> n >> m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin >> c;
			if(c=='.'){
				a[i][j]=1;
			}
			else{
				a[i][j]=0;
			}
		}
	}
	go(1,1);
	if(tf==true){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}
2024/5/29 17:38
加载中...