求助WA134
查看原帖
求助WA134
1045061
2005citiwujie楼主2024/1/21 18:53

想不明白啊,先初始化dp数组为啥不行,求助

#include<bits/stdc++.h>
using namespace std;
const int N=1e3+10;
#define int long long
int dp[N][N],n,m,m1,m2,dx[]={0, -2, -1, 1, 2, 2, 1, -1, -2},dy[]={0, 1, 2, 2, 1, -1, -2, -2, -1};
bool p[N][N];
signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m>>m1>>m2;
	for(int i=0;i<=m;i++) dp[0][i]=1;
	for(int j=0;j<=n;j++) dp[j][0]=1;
	for(int i=0;i<9;i++) if(m1+dx[i]>=0&&m2+dy[i]>=0) p[m1+dx[i]][m2+dy[i]]=true;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(p[i][j]) continue;
			dp[i][j]=dp[i-1][j]+dp[i][j-1];
		}
	}
	cout<<dp[n][m]<<"\n"; 
    return 0;
}
2024/1/21 18:53
加载中...