社区讨论
关于我在本地测试点一和样例都对了而全 WA 这回事
P1002[NOIP 2002 普及组] 过河卒参与者 2已保存回复 4
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 4 条
- 当前快照
- 1 份
- 快照标识符
- @m279642x
- 此快照首次捕获于
- 2024/10/13 15:17 去年
- 此快照最后确认于
- 2025/11/04 17:17 4 个月前
CPP
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
bool st[25][25];
int dp[25][25];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
memset(st, 0, sizeof(st));
int n, m, hx, hy;
cin >> n >> m >> hx >> hy;
st[hx][hy] = 1;
if (hx - 2 >= 0) st[hx - 2][hy + 1] = 1;
if (hx - 2 >= 0 && hy - 1 >= 0) st[hx - 2][hy - 1] = 1;
if (hx - 1 >= 0) st[hx - 1][hy + 2] = 1;
if (hx - 1 >= 0 && hy - 2 >= 0) st[hx - 1][hy - 2] = 1;
if (hy - 2 >= 0) st[hx + 1][hy - 2] = 1;
st[hx + 1][hy + 2] = 1;
if (hy - 1 >= 0) st[hx + 2][hy - 1] = 1;
st[hx + 2][hy + 1] = 1;
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= m; j++) {
if (!st[i][j]) {
if (i == 0 && j == 0)
dp[i][j] = 1;
else
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
}
}
}
cout << dp[n][m] << "\n";
return 0;
}
回复
共 4 条回复,欢迎继续交流。
正在加载回复...