What?
  • 板块P1605 迷宫
  • 楼主chenbingjie
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/9/20 18:33
  • 上次更新2024/9/20 19:50:06
查看原帖
What?
1268625
chenbingjie楼主2024/9/20 18:33
#include<iostream>
using namespace std;
int f[10][10];
int cnt,n,m,stx,sty,enx,eny;
void dfs(int nowx,int nowy){
	if(nowx<1||nowx>m)return;
	if(nowy<1||nowy>n)return;
	if(f[nowx][nowy]==1||f[nowx][nowy]==2)return;
	if(nowx==enx&&nowy==eny)cnt++;return;
	f[nowx][nowy]=1;
	dfs(nowx+1,nowy);
	dfs(nowx,nowy+1);
	dfs(nowx-1,nowy);
	dfs(nowx,nowy-1);
	f[nowx][nowy]=0;
	return;
}
int main(){
	int t;
	cin>>n>>m>>t;
	cin>>stx>>sty>>enx>>eny;
	for(int i=1;i<=t;i++){
		int x,y;
		cin>>x>>y;
		f[x][y]=2;
	}
	dfs(stx,sty);
	cout<<cnt;
	return 0;
}

大佬帮忙看一看,为什么一直输出零

2024/9/20 18:33
加载中...