30分!
  • 板块P1605 迷宫
  • 楼主WindowsWKP
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/1/27 17:32
  • 上次更新2024/1/27 19:41:11
查看原帖
30分!
889093
WindowsWKP楼主2024/1/27 17:32
#include<bits/stdc++.h>
using namespace std;
int maze[10][10],ans;
bool a[10][10];
int n,m,t,sx,sy,fx,fy,x,y;
void dfs(int X,int Y){
	if (X==fx&&Y==fy){
		ans++;
		return;
	}
	for (int i=sx,j=sy;i<n&&j<m;i++,j++){
		if (maze[i][j]==0&&a[i][j]==0){
			a[i][j]=1;
			dfs (X-1,Y);
			dfs (X+1,Y);
			dfs (X,Y-1);
			dfs (X,Y+1);
			a[i][j]=0;
		}
	}
}
int main(){
	cin>>n>>m>>t;
	cin>>sx>>sy>>fx>>fy;
	for (int i=1;i<=t;i++){
		cin>>x>>y;
		maze[x][y]=1;
	}
	dfs (sx,sy);
	cout<<ans;
	return 0;
}
2024/1/27 17:32
加载中...