WA on #2,#7,#8

P1605 迷宫

求调
by 已注销fXY$ThLk @ 2022-10-22 13:02:31


初始点走过了,所以vis应该是1
by _wjr_ @ 2022-10-22 13:25:44


```cpp #include<bits/stdc++.h> using namespace std; int vis[6][6]; int n,m,t;//迷宫的长宽和障碍总数 int sx,sy,fx,fy;//SX,SY代表起点坐标,FX,FY代表终点坐标 int ans;//方案总数 bool pd(int x,int y){ if(vis[x][y]>=1) return false; if(x>n || x<1) return false; if(y>m || y<1) return false; return true; } void dfs(int x,int y){ if(x==fx && y==fy){ ans++; return; } int x2,y2; x2=x+1,y2=y; if(pd(x2,y2)){ vis[x2][y2]=1; dfs(x2,y2); vis[x2][y2]=0; } x2=x-1,y2=y; if(pd(x2,y2)){ vis[x2][y2]=1; dfs(x2,y2); vis[x2][y2]=0; } x2=x,y2=y+1; if(pd(x2,y2)){ vis[x2][y2]=1; dfs(x2,y2); vis[x2][y2]=0; } x2=x,y2=y-1; if(pd(x2,y2)){ vis[x2][y2]=1; dfs(x2,y2); vis[x2][y2]=0; } return; } int main(){ cin>>n>>m>>t; cin>>sx>>sy>>fx>>fy; int z1,z2;//障碍 for(int i=1;i<=t;i++){ cin>>z1>>z2; vis[z1][z2]=9;//不能走 } vis[sx][sy] = 1; dfs(sx,sy); cout<<ans; return 0; } ```
by _wjr_ @ 2022-10-22 13:26:20


@[Death_wjr](/user/549910) 过了,感谢!
by 已注销fXY$ThLk @ 2022-10-22 13:32:42


|