70分求助 【捂脸】
查看原帖
70分求助 【捂脸】
550532
LS时空光影楼主2021/12/1 22:13
#include <iostream>
#include <cstdio>
using namespace std;
int n,m,i,x,y,x1,y1,x2,y2,t,ans,f[10][10];
int tmp[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
void sc(int x,int y){
	int xx,yy;
	if(x==x2 && y==y2){
		ans++;
		return ;
	}
	for(int i=0;i<4;i++){
		xx=x+tmp[i][0];
		yy=y+tmp[i][1];
		if(xx>=1 && xx<=n && yy>=1 && yy<=m)
			if(f[xx][yy]==0){
				f[xx][yy]=1;
				sc(xx,yy);
				f[xx][yy]=0;
			}
	}
	return ;
}
int main(){
	scanf("%d%d%d",&n,&m,&t);
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	for(i=1;i<=t;i++) scanf("%d%d",&x,&y),f[x][y]=1;
	sc(x1,y1);
	printf("%d\n",ans);
	return 0;
}
2021/12/1 22:13
加载中...