#144 为什么只有60分

Kinghero King of the summit 2023-07-14 18:45:26 2023-07-14 18:45:57 0

接下来,上60分code

#include <bits/stdc++.h>
#define maxn 100  //马占有的地方以及能一步到的地方赋为10000

using namespace std;
int main() {
    freopen("C.in", "r", stdin);
    freopen("C.out", "w", stdout);
    int n, m;
    long int a[21][21];
    int xm, ym;               // xm,ym表示马的坐标
    memset(a, 0, sizeof(a));  //二维数组元素初始化为0
    cin >> n >> m >> xm >> ym;
    a[xm][ym] = maxn;  //马占有的地方赋为maxn
    int i, j;
    for (j = ym - 1; j <= ym + 1; j += 2)  //马能一步到达的坐标赋为maxn
        for (i = xm - 2; i <= xm + 2; i += 4) {
            if (i < 0 || j < 0)
                continue;
            else
                a[i][j] = maxn;
        }
    for (i = xm - 1; i <= xm + 1; i += 2)  //处理马能一步到达的坐标赋为maxn
        for (j = ym - 2; j <= ym + 2; j += 4) {
            if (i < 0 || j < 0)
                continue;
            else
                a[i][j] = maxn;
        }

    for (i = n; i >= 0; i--)
        for (j = m; j >= 0; j--) {
            if (a[i][j] == maxn)  //马占有的地方不用赋值了
                continue;
            if (i == n || j == m)  //边界处理,由于卒只能往右,往下走,此边界只有一条路
                a[i][j] = 1;
            else if (a[i][j + 1] == maxn && a[i + 1][j] == maxn)
                a[i][j] = maxn;
            else if (a[i][j + 1] == maxn && a[i + 1][j] != maxn)
                a[i][j] = a[i + 1][j];
            else if (a[i][j + 1] != maxn && a[i + 1][j] == maxn)
                a[i][j] = a[i][j + 1];
            else
                a[i][j] = a[i][j + 1] + a[i + 1][j];  //正常情况
        }
    cout << a[0][0];
}
{{ vote && vote.total.up }}