WA两个点60分求助
查看原帖
WA两个点60分求助
325157
Luo_gu_fyh楼主2022/8/4 10:03
#include <bits/stdc++.h>

using namespace std;

const int dx[] = {-2, -2, -1, 1, 2, 2, 1, -1};
const int dy[] = {-1, 1, 2, 2, 1, -1, -2, -2};
int a[25][25], n, m, x, y;
bool f[25][25];

int main(){
  cin >> n >> m >> x >> y;
  a[0][0] = 1;
  f[x][y] = 1;
  for(int i = 0; i < 8; i++){
    int nx = dx[i] + x, ny = dy[i] + y;
    if(nx >= 0 && nx <= n && ny >= 0 && ny <= m) {
      f[nx][ny] = 1;
    }
  }
  for(int i = 1; i <= n; i++){
    if(!f[i][0]){
      a[i][0] = a[i - 1][0];
    }
  }
  for(int i = 1; i <= m; i++){
    if(!f[0][i]){
      a[0][i] = a[0][i - 1];
    }
  }
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= m; j++){
      if(!f[i][j]){
        a[i][j] = a[i - 1][j] + a[i][j - 1];
      }
    }
  }
  cout << a[n][m];
  return 0;
}

2022/8/4 10:03
加载中...