为啥第5个wa
查看原帖
为啥第5个wa
320883
白面葫芦娃楼主2020/6/7 11:19
#include <iostream>
using namespace std;
long long n,m,map[25][25],dp[25][25]={0};
int main(){
	int x,y;
	cin>>n>>m>>x>>y;
	map[x][y]=1;
	if(x-2>=0 && x-2<=n && y+1>=0 && y+1<=m) map[x-2][y+1]=1;
	if(x-1>=0 && x-1<=n && y+2>=0 && y+2<=m) map[x-1][y+2]=1;
	if(x+1>=0 && x+1<=n && y+2>=0 && y+2<=m) map[x+1][y+2]=1;
	if(x+2>=0 && x+2<=n && y+1>=0 && y+1<=m) map[x+2][y+1]=1;
	if(x+2>=0 && x+2<=n && y-1>=0 && y-1<=m) map[x+2][y-1]=1;
	if(x+1>=0 && x+1<=n && y-2>=0 && y-2<=m) map[x+1][y-2]=1;
	if(x-1>=0 && x-1<=n && y-2>=0 && y-2<=m) map[x-1][y-2]=1;
	if(x-2>=0 && x-2<=n && y-1>=0 && y-1<=m) map[x-2][y-1]=1;
	for(int i=0;i<=n;i++){ 
		if(!map[i][0]) dp[i][0]=1;
		else break;
	} 
	for(int i=0;i<=n;i++){
		if(!map[0][i]) dp[0][i]=1;
		else break;
	} 
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(!map[i][j]) dp[i][j]=dp[i-1][j]+dp[i][j-1];
	/*for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			cout<<dp[i][j]<<" ";
		} 
		cout<<endl;
	}*/
	cout<<dp[n][m]<<endl;
	return 0;
} 
2020/6/7 11:19
加载中...