P1605,90分求调
  • 板块题目总版
  • 楼主chenhx
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/8/4 08:07
  • 上次更新2024/8/4 10:15:54
查看原帖
P1605,90分求调
803874
chenhx楼主2024/8/4 08:07
#include<bits/stdc++.h>
using namespace std;
int n,m,sx,sy,ex,ey,t,vis[6][6],dx[4]={0,0,1,-1},dy[4]={-1,1,0,0},cnt,tx,ty;
bool markk[6][6];
void dfs(int x,int y){
	if(x==ex&&y==ey){
		cnt++;
		return;
	}else{
		for(int i=0;i<4;i++){
			int fx=x+dx[i];
			int fy=y+dy[i];
			if(markk[fx][fy]==0&&vis[fx][fy]==1){
				markk[x][y]=1;
				dfs(fx,fy);
				markk[x][y]=0;
			}
		}
	}
}
int main(){
cin>>n>>m>>t;
for(int i=1;i<=n;i++){
	for(int j=1;j<=m;j++){
		vis[i][j]=1;
	}
}
cin>>sx>>sy;
cin>>ex>>ey;
for(int i=1;i<=t;i++){
	cin>>tx>>ty;
	vis[tx][ty]=0;
}
dfs(sx,sy);
cout<<cnt;
return 0;
}
2024/8/4 08:07
加载中...