5wa求助,dp,自测样例、1、2点均无问题
查看原帖
5wa求助,dp,自测样例、1、2点均无问题
794048
ww_fenhua楼主2022/11/13 00:20
#include<bits/stdc++.h>
using namespace std;
long long arr[22][22];
long long cx[22][22];long long res;
long long x1,y11,x2,y2;

int dfs(int x,int y)
{
	if(x>x1)return 0;
	if(y>y11)return 0;
	if(arr[x][y]==-1)return 0;
	
	if(cx[x][y]>0)return cx[x][y];
	long long ans1=dfs(x+1,y);
	long long ans2=dfs(x,y+1);
	cx[x][y]=ans1+ans2+cx[x][y];
}

int main()
{
	
	
	scanf("%lld%lld%lld%lld",&x1,&y11,&x2,&y2);
	cx[x1-1][y11]=1;
	cx[x1][y11-1]=1;
	
	arr[x2][y2]=-1;
	if(y2-1>=0)if(x2-2>=0)arr[x2-2][y2-1]=-1;
	if(y2+1<=20)if(x2-2>=0)arr[x2-2][y2+1]=-1;
	if(y2-1>=0)if(x2+2<=20)arr[x2+2][y2-1]=-1;
	if(y2+1<=20)if(x2+2<=20)arr[x2+2][y2+1]=-1;
	if(y2-2>=0)if(x2-1>=0)arr[x2-1][y2-2]=-1;
	if(y2+2<=20)if(x2-1>=0)arr[x2-1][y2+2]=-1;
	if(y2-2>=0)if(x2-1<=20)arr[x2+1][y2-2]=-1;
	if(y2+2<=20)if(x2-1<=20)arr[x2+1][y2+2]=-1;
	
	if(arr[x1][y11]!=-1)res=dfs(0,0);
	
    
	printf("%lld\n",res);
	
	return 0;
}
2022/11/13 00:20
加载中...