dp50分求助
  • 板块P1605 迷宫
  • 楼主W0718
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/7/12 09:12
  • 上次更新2024/7/12 10:47:45
查看原帖
dp50分求助
776751
W0718楼主2024/7/12 09:12

dp50分求助!!!!!

#include<bits/stdc++.h>
using namespace std;
const int maxn=10+111;
int n,m,t;
int sx,sy,fx,fy;
int zx[maxn],zy[maxn];
int z[maxn][maxn];
int dp[maxn][maxn];
int main()
{
	scanf("%d %d %d",&n,&m,&t);
	scanf("%d %d %d %d",&sx,&sy,&fx,&fy);
	for(int i=1;i<=t;i++)
	{
		scanf("%d %d",&zx[i],&zy[i]);
		z[zx[i]][zy[i]]=1;
	}
	dp[1][1]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(z[i][j]!=1)
			{
				dp[i][j]+=dp[i-1][j]+dp[i][j-1]+dp[i+1][j]+dp[i][j+1];
			}
			else dp[i][j]=0;
		}
	}
	printf("%d",dp[n][m]);
	return 0;
}
2024/7/12 09:12
加载中...