三四死活过不了,有没有佬看看
查看原帖
三四死活过不了,有没有佬看看
525303
_small_town_swot楼主2024/3/8 15:39
#include <iostream>
#include <vector>


class Vector2{
  public:
  int x;
  int y;
};

namespace version1 {
  class Solution {
    public:
    static long long result(Vector2 b_point, Vector2 h_point) {
      std::vector<Vector2> defence_point = {
        Vector2{-2, -1},
        Vector2{-2, 1},
        Vector2{-1, -2},
        Vector2{-1, 2},
        Vector2{2, -1},
        Vector2{2, 1},
        Vector2{1, -2},
        Vector2{1, 2}
      };
      std::vector<std::vector<long long>> board(40, std::vector<long long>(40, 1));
      board[h_point.x][h_point.y] = 0;
      for (auto & i : defence_point) {
        board[h_point.x + i.x][h_point.y + i.y] = 0;
      }

      for (int i = 3; i < b_point.x + 1; i++) {
        for (int j = 3; j < b_point.y + 1; j++) {
          if (board[i][j] == 0) {
            continue;
          } else {
            board[i][j] = board[i - 1][j] + board[i][j - 1];
          }
        }
      }

      // 		for (const auto& row: board) {
      // 			for (auto col: row) {
      // 				std::cout << col << " ";
      // 			}
      // 			std::cout << std::endl;
      // 		}

      return board[b_point.x][b_point.y];
    }
  };
}

int main() {
  Vector2 b_point{};
  Vector2 h_point{};
  std::cin >> b_point.x >> b_point.y >> h_point.x >> h_point.y;
  b_point.x += 2;
  b_point.y += 2;
  h_point.x += 2;
  h_point.y += 2;
  long long result = version1::Solution::result(b_point, h_point);

  std::cout << result << std::endl;
  return 0;
}
2024/3/8 15:39
加载中...