90求调
查看原帖
90求调
1282740
God_nodog_lhj楼主2024/11/2 16:36
#include <bits/stdc++.h>
using namespace std;
int n,m,t,a[6][6],s1,s2,f1,f2,xx,yy,ans;
void f(int x,int y){
	if(x==f1&&y==f2){
		ans++;
		return ;
	}
	a[x][y]=1;
	for(int xx=-1;xx<=1;xx++){
	    for(int yy=-1;yy<=1;yy++){
	        if(abs(yx)+abs(yy)!=1) continue;
	        int xxx=x+xx,yyy=y+yy;
	        if(xxx>=1&&xxx<=n&&yyy>=1&&yyy<=m&&a[xxx][yyy]==0){
	            f(xxx,yyy);
	        }
	    }
	}
	a[x][y]=0;
}
int main(){
    cin>>n>>m>>t;
    cin>>s1>>s2>>f1>>f2;
    for(int i=1;i<=n;i++){
		cin>>xx>>yy;
		a[xx][yy]=-1;
	}
    a[s1][s2]=1;
	f(s1,s2);
	cout<<ans;
	return 0;
}
2024/11/2 16:36
加载中...