70分求助各位大佬

P1605 迷宫

看看我的: ```cpp #include<bits/stdc++.h> using namespace std; int n,m,t,sx,sy,sum,fx,fy,ax,ay,bx[4]={-1,1,0,0},by[4]={0,0,-1,1},a[11][11]; void dfs(int x,int y){ if(x==fx&&y==fy){ sum++; } else{ for(int i=0;i<4;i++){ int l=x+bx[i]; int r=y+by[i]; if(l<=n&&r<=m&&l>=1&&r>=1&&a[l][r]!=1){ a[l][r]=1; dfs(l,r); a[l][r]=0; } } } } int main() { cin>>n>>m>>t>>sx>>sy>>fx>>fy; for(int i=0;i<t;i++){ cin>>ax>>ay; a[ax][ay]=1; } a[sx][sy]=1; dfs(sx,sy); cout<<sum; return 0; } ```
by luoguandy @ 2024-01-01 20:14:10


@[zjh20081205](/user/616712) 将a[bx][by]的初值设为1.
by __zaa__ @ 2024-01-01 20:29:32


@[__zaa__](/user/716965) 谢谢大佬!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
by zjh20081205 @ 2024-01-01 20:45:30


|