为什么全是WA?下载了输入输出数据在本地跑也是正确的
查看原帖
为什么全是WA?下载了输入输出数据在本地跑也是正确的
1056802
TTTTorch楼主2024/5/28 20:49
#include <iostream>
using namespace std;

long long int a[25][25];
int dir[8][2] = {{-2, -1}, {-1, -2}, {2, 1}, {1, 2}, {-2, 1}, {-1, 2}, {2, -1}, {1, -2}};

int main()
{
      int row, col, n, m;
      cin >> row >> col >> n >> m;
      for (int i = 0; i <= row; i++)
      {
            for (int j = 0; j <= col; j++)
            {
                  a[i][j] = 1;
            }
      }
      for (int i = 0; i < 8; i++)
      {
            int tempx, tempy;
            tempx = n + dir[i][0];
            tempy = m + dir[i][1];
            if ((tempx >= 0 && tempx <= row) && (tempy >= 0 && tempy <= col))
            {
                  a[tempx][tempy] = 0;
            }
      }
      a[n][m] = 0;
      a[0][0] = 1;
      for (int i = 0; i <= row; i++)
      {
            for (int j = 0; j <= col; j++)
            {
                  if (a[i][j] == 0)
                  {
                        continue;
                  }
                  if (i == 0)
                  {
                        a[0][j] = a[0][j-1];
                  }
                  else if (j == 0)
                  {
                        a[i][0] = a[i-1][0];
                  }
                  else
                  {
                        a[i][j] = a[i - 1][j] + a[i][j - 1];
                  }
            }
      }
      cout << a[row][col];
      return 0;
}
2024/5/28 20:49
加载中...