求助万能的谷民
  • 板块灌水区
  • 楼主Little_Cabbage
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/6/10 09:33
  • 上次更新2023/10/23 13:32:04
查看原帖
求助万能的谷民
730195
Little_Cabbage楼主2023/6/10 09:33

题目:

代码:

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define db double
using namespace std;
const ll N = 1e7;
ll n, m, dp[1010][1010], x[100010], y[100010];

bool ok(ll a, ll b) {
	for (int i = 1; i <= m; i++)
		if (x[i] == a && y[i] == b)
			return true;
	return false;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> x[i] >> y[i];
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++) {
			if (ok(i, j))
				dp[i][j] = 0;
			else if (i == 1 && j == 1)
				dp[i][j] = 1;
			else if (i == 1)
				dp[i][j] = dp[i][j - 1];
			else if (j == 1)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
		}
	for (int i = 1; i <= n; cout << endl, i++)
		for (int j = 1; j <= n; j++)
			cout << dp[i][j] << ' ';
//	cout << dp[n][n] % 100003;
	return 0;
}
2023/6/10 09:33
加载中...