Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
110909 廖悦扬 过河卒 C++ 通过 100 0 MS 256 KB 1016 2023-11-17 18:03:47

Tests(5/5):


#include <iostream> using namespace std; long long dp[25][25] = {0}; int main() { int b_x, b_y, hor_x, hor_y; cin >> b_y >> b_x >> hor_y >> hor_x; if (hor_x-2>=0&&hor_y-1>=0) dp[hor_x-2][hor_y-1] = -1; if (hor_x-1>=0&&hor_y-2>=0) dp[hor_x-1][hor_y-2] = -1; if (hor_x-2>=0) dp[hor_x-2][hor_y+1] = -1; if (hor_x-1>=0) dp[hor_x-1][hor_y+2] = -1; if (hor_y-2>=0) dp[hor_x+1][hor_y-2] = -1; if (hor_y-1>=0) dp[hor_x+2][hor_y-1] = -1; dp[hor_x+1][hor_y+2] = -1; dp[hor_x+2][hor_y+1] = -1; dp[hor_x][hor_y] = -1; int i, j; dp[0][0] = 1; for (i=1; i<=b_x; i++) { if (dp[i][0] == -1) dp[i][0] =0; else dp[i][0] = dp[i-1][0]; } for (i=1; i<=b_y; i++) { if (dp[0][i] == -1) dp[0][i] =0; else dp[0][i] = dp[0][i-1]; } for (i=1; i<=b_x; i++) { for (j=1; j<=b_y; j++) { if (dp[i][j] == -1) { dp[i][j] = 0; } else if (i != 0 && j!=0) { dp[i][j] = dp[i-1][j] + dp[i][j-1]; } } } cout << dp[b_x][b_y] << endl; return 0; }


测评信息: