TLE在意料之中,RE是为啥呢
查看原帖
TLE在意料之中,RE是为啥呢
626785
lxc_awa楼主2022/10/30 20:15

rt

#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,v[10001][10001],ans=0;
void dfs(int x,int y){
	if(x==n&&y==m){
		ans++;
		return;
	}
	if(x>=0&&x<=n&&y>=0&&y<=m&&v[x][y]==0){
		v[x][y]=1;
		dfs(x+1,y);
		dfs(x,y+1);
		v[x][y]=0;
	}
}
int main(){
//	freopen("text.in","r",stdin);
//	freopen("text.out","w",stdout);
	cin>>n>>m>>a>>b;
	v[a][b]=-1;
	v[a-2][b-1]=-1;
	v[a-2][b+1]=-1;
	v[a+2][b-1]=-1;
	v[a+2][b+1]=-1;
	v[a-1][b-2]=-1;
	v[a-1][b+2]=-1;
	v[a+1][b-2]=-1;
	v[a+1][b+2]=-1;
	dfs(0,0);
	cout<<ans;
	return 0;
}

2022/10/30 20:15
加载中...