60pts求调

B3625 迷宫寻路

Dream_In_Night @ 2024-10-12 19:55:03

//Name:Lazy_doghead
#include<bits/stdc++.h>
using namespace std;
bool op[31][31],ot;
char a[31][31];
void ptdfs(int dx,int dy,int k,int o){
    if(a[k][o]=='#')return;
    op[k][o]=true;
    if(k==dx&&o==dx){
        ot=true;
        return;
    }
    if(k-1>0&&!(op[k-1][o]))ptdfs(dx,dy,k-1,o);
    if(k+1<=dx&&!(op[k+1][o]))ptdfs(dx,dy,k+1,o);
    if(o-1>0&&!(op[k][o-1]))ptdfs(dx,dy,k,o-1);
    if(o+1<=dy&&!(op[k][o+1]))ptdfs(dx,dy,k,o+1);
    op[k][o]=false;
    return;
}
void ys(){
    int n,m,i,j,t;
    cin>>n>>m;
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++)cin>>a[i][j];
    }
    ptdfs(n,m,1,1);
    if(ot)cout<<"Yes";
    else cout<<"No";
}
int main(){
    ys();
    return 0;
}

调了半天了,悬赏一关


by Dream_In_Night @ 2024-10-12 20:08:09

调成101就T掉


|