样例没过,却AC??

B3625 迷宫寻路

duyuchen20204 @ 2024-08-06 16:34:10

???

#include<bits/stdc++.h>
using namespace std;
int a,v[105][105],b,c,w[4][2]={{-1,0},{0,1},{1,0},{0,-1}},n,flag;
char m[105][105];
void sb(int s,int y){
    if(s==a&&y==b){
        cout<<"Yes";
        flag=1;
        return;
    }
    int dx,dy;
    for(int i=0;i<4;i++){
        int dx=s+w[i][0];
        int dy=y+w[0][i];
        if(dx<1||dx>a||dy<1||dy>b||m[dx][dy]=='#'||v[dx][dy]==1){
            continue;
        }
        v[dx][dy]=1;
        sb(dx,dy);
    }
} 
int main(){
    cin>>a>>b;
    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++){
            cin>>m[i][j];
        }
    }
    sb(1,1);
    if(flag==0){
        cout<<"No";
    }
    return 0;
}

by Fractured_Angel @ 2024-08-06 16:36:21

int dx=s+w[i][0]
int dy=y+w[0][i];

你能告诉我你自己写的什么东西吗?


by qujunhao @ 2024-08-06 16:55:38

int dx=s+w[i][0] int dy=y+w[0][i]; 你能告诉我你自己写的什么东西吗?


by qujunhao @ 2024-08-06 16:56:00


by duyuchen20204 @ 2024-08-06 16:56:14

没看到我之前写反了我改回来了

int dx=s+w[i][0];

int dy=y+w[i][1];

谢谢,已关


|