dp 20wa了
查看原帖
dp 20wa了
544007
lhs_chris楼主2023/5/23 21:00
#include<bits/stdc++.h>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define ll long long
using namespace std;
const int N=1e5+10;
const int M=2023;
const int inf=0x3f3f3f3f;
ll n,m,hx,hy,h[10][10],f[50][50]; 
int main()
{
	cin>>n>>m>>hx>>hy;
	f[1][1]=1;
	h[hx+1][hy+1]=1;
	h[hx-2+1][hy-1+1]=1;
	h[hx-2+1][hy+1+1]=1;
	h[hx-1+1][hy-2+1]=1;
	h[hx-1+1][hy+2+1]=1;
	h[hx+1+1][hy-2+1]=1;
	h[hx+1+1][hy+2+1]=1;
	h[hx+2+1][hy-1+1]=1;
	h[hx+2+1][hy+1+1]=1;
	for(int i=1;i<=n+1;i++)
	{
		for(int j=1;j<=m+1;j++)
		{
			if(h[i][j]==1)
			{
				f[i][j]=0;
			}
		}
	}
	for(int i=1;i<=n+1;i++)
	{
		for(int j=1;j<=m+1;j++)
		{
			if(h[i][j]==0)
			{
				f[i][j]=(f[i-1][j]+f[i][j-1]);
				f[1][1]=1;
			}
		}
	}
	for(int i=1;i<=n+1;i++)
	{
		for(int j=1;j<=m+1;j++)
		{
			cout<<f[i][j]<<" ";
		}
		cout<<"\n";	
	}
	cout<<f[n+1][m+1];
	return 0;
}
2023/5/23 21:00
加载中...