90分求助
  • 板块P1605 迷宫
  • 楼主cccckick
  • 当前回复2
  • 已保存回复2
  • 发布时间2025/1/7 12:51
  • 上次更新2025/1/7 20:36:07
查看原帖
90分求助
1449927
cccckick楼主2025/1/7 12:51
#include<bits/stdc++.h>
using namespace std;
int n,m,t;
int bx,by,ex,ey;
int cot;
int c[100][100];
void dfs(int x,int y)
{
	if(x==ex&&y==ey)
	{cot++;
	 return;
	}
	if(x<1||y<1||y>m||x>n)
	return;
	if(c[x][y]==1)
	return;
c[x][y]=1;
dfs(x+1,y);
dfs(x-1,y);
dfs(x,y+1);
dfs(x,y-1);	
c[x][y]=0;	
}
int main()
{
	 cin>>n>>m>>t;
	 cin>>bx>>by>>ex>>ey;
	 for(int i=1;i<=t;i++)
	 {int x,y;
	 	 cin>>x>>y;
	 	 c[x][y]=1;
	 }
dfs(bx,by);
	 cout<<cot;
}
2025/1/7 12:51
加载中...