社区讨论

40分一直是1、、、、、

P1605迷宫参与者 3已保存回复 4

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
4 条
当前快照
1 份
快照标识符
@mi6vkf2b
此快照首次捕获于
2025/11/20 11:31
4 个月前
此快照最后确认于
2025/11/20 11:31
4 个月前
查看原帖
#include #include using namespace std; bool map[6][6],temp[6][6]; int n,m,d[5]={-1,0,1,0,-1}; int sx,sy,fx,fy,sum; void dfs(int x,int y) { if(x==fx&&y==fy) sum++; for(int i=0;i<4;i++) { int l=x+d[i]; int r=y+d[i+1]; if(l>=1&&r>=1&&l<=n&&r<=m&&!map[l][r]&&!temp[l][r]) { temp[l][r]=true; dfs(l,r); temp[l][r]; } } return ; } int main(){ int t,tx,ty; cin>>n>>m>>t; cin>>sx>>sy>>fx>>fy; map[sx][sy]=true; for(int i=0;i<t;i++) { cin>>tx>>ty; map[tx][ty]=true; } dfs(sx,sy); cout<<sum<<endl; return 0; }

回复

4 条回复,欢迎继续交流。

正在加载回复...