大牛来帮看看,错了一个点,记忆化dfs

评测结果
编译成功

测试数据 #0: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #2: WrongAnswer, time = 0 ms, mem = 560 KiB, score = 0
测试数据 #3: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #6: Accepted, time = 0 ms, mem = 556 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 560 KiB, score = 10
测试数据 #9: Accepted, time = 0 ms, mem = 560 KiB, score = 10
WrongAnswer, time = 0 ms, mem = 560 KiB, score = 90
代码
#include <iostream>
using namespace std;
const int X[8] = {1,-1,1,-1,-2,-2,2,2};
const int Y[8] = {-2,-2,2,2,-1,1,1,-1};
int m,n,ans = 0,xx,yy,dp[31][31];
bool No[31][31];
inline int dfs(int x,int y) {
  if (x < 0 || y < 0 || No[x][y]) return 0;
  if (x == 0 && y == 0) return 1;
  if (dp[x][y]) return dp[x][y];
  else return dp[x][y] = dfs(x-1,y)+dfs(x,y-1);
}
int main() {
  ios :: sync_with_stdio(false);
  cin >> n >> m >> xx >> yy;
  No[xx][yy] = true;
  for (int i = 0;i < 8;i++)
    if(yy+Y[i] >= 1 && xx+X[i] >= 1) No[xx+X[i]][yy+Y[i]] = true;
  cout << dfs(n,m);
  return 0;
}

0 条评论

目前还没有评论...

信息

ID
1121
难度
4
分类
动态规划 点击显示
标签
递交数
9583
已通过
3786
通过率
40%
被复制
25
上传者