40pts紧急求助
查看原帖
40pts紧急求助
1097177
longhaoyuan楼主2024/5/28 21:42
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 25;

int n, m, hx, hy;
ll dp[maxn][maxn];
set<pair<int, int>> forbidden; 

int main(){
	scanf("%d %d %d %d", &n, &m, &hx, &hy);
	forbidden.emplace(hx, hy);
	for (int i = -2; i <= 2; i++){
		if (!i) continue;
		for (int j = -2; j <= 2; j++){
			if (!j) continue;
			if (abs(i) + abs(j) != 3) continue;
			forbidden.emplace(hx+i, hy+j);
		}
	}
	for (int i = 0; i <= n; i++){
		dp[0][i] = !forbidden.count({0, i});
		dp[i][0] = !forbidden.count({i, 0});
	}
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (forbidden.count({i, j})) dp[i][j] = 0LL;
			else dp[i][j] = dp[i-1][j] + dp[i][j-1];
		}
	}
	printf("%lld", dp[n][m]);
	return 0;
}

不知道为什么是40十分,请大佬求助QwQ

2024/5/28 21:42
加载中...