RE求助
  • 板块P1605 迷宫
  • 楼主Touch_head
  • 当前回复6
  • 已保存回复6
  • 发布时间2023/9/20 18:58
  • 上次更新2023/11/2 18:58:20
查看原帖
RE求助
540068
Touch_head楼主2023/9/20 18:58
#include<bits/stdc++.h>
using namespace std;
int n,m,t;
int ans;
int sx,sy,fx,fy;
int dx[5]={0,1,-1,0,0},dy[5]={0,0,0,-1,1};
int a[11][11];
void dfs(int x,int y){
	if(x==fx&&y==fy){
		ans++;
		return ;
	}
	if(x<sx||y<sy||x>fx||y>fy||a[x][y]==1){
		return ;
	}
	for(int i=1;i<=4;i++){
		dfs(x+dx[i],y+dy[i]);
	}
}
int main(){
	cin>>n>>m>>t;
	cin>>sx>>sy>>fx>>fy;
	while(t--){
		int x,y;
		cin>>x>>y;
		a[x][y]==1;	
	}
	dfs(sx,sy);
	cout<<ans;
	return 0;
}
2023/9/20 18:58
加载中...