啊啊啊我的思路没问题吧
  • 板块P1605 迷宫
  • 楼主Optics
  • 当前回复3
  • 已保存回复3
  • 发布时间2022/5/26 22:03
  • 上次更新2023/10/28 00:34:15
查看原帖
啊啊啊我的思路没问题吧
511229
Optics楼主2022/5/26 22:03
#include <bits/stdc++.h>
using namespace std;
int n,m,t,sx,sy,fx,fy,x,y;
int cnt;
int dx[4] = {0,1,-1,0};
int dy[4] = {1,0,0,-1};
bool a[10][10];
void dfs(int xx,int yy) {
	if(xx == fx && yy == fy){
		cnt++;
		return;
	}
	for(int i = 0; i < 4; i++){
		int qx = xx + dx[i];
		int qy = yy + dy[i];
		if(a[qx][qy] == 0){
			a[xx][yy] = 1;
			dfs(qx,qy);
			a[xx][yy] = 0;
		}
	}
}
int main()
{
	cin >> n >> m >> t;
	cin >> sx >> sy >> fx >> fy;
	for(int i = 1; i <= t; i++){
		cin >> x >> y;
		a[x][y] = 1;
	}
	dfs(sx,sy);
	return 0;
}

2022/5/26 22:03
加载中...