HDU FatMouse and Cheese
来源:互联网 发布:淘宝网页无法显示图片 编辑:程序博客网 时间:2024/05/20 00:17
#include<iostream>
#include<string.h>
#include<algorithm>
int n, k, map[102][102], d[4][2] = { {1,0},{-1,0},{0,1},{0,-1} },sum[102][102];
using namespace std;
int main()
{
int dfs(int,int);
while (cin >> n >> k&&(n+k)!=-2)
{
memset(sum, 0, sizeof(sum));
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
cin >> map[i][j];
cout << dfs(0, 0) << endl;
}
return 0;
}
int dfs(int x,int y)
{
if (sum[x][y]) return sum[x][y];
int s = 0;
for (int i = 0; i < 4; i++)
{
for (int j = 1; j <= k; j++)
{
int x1 = x + d[i][0] * j, y1 = y + d[i][1] * j;
if (x1 < 0 || x1 >= n || y1 < 0 || y1 >= n) continue;
if (map[x1][y1] <= map[x][y]) continue;
int ll=dfs(x1, y1);
s = max(ll, s);
}
}
sum[x][y] = s + map[x][y];
return sum[x][y];
}
- FatMouse and Cheese HDU
- HDU FatMouse and Cheese
- HDU 1078 FatMouse and Cheese
- HDU 1107 FatMouse and Cheese
- hdu 1078 FatMouse and Cheese
- hdu 1078 FatMouse and Cheese
- hdu 1078 FatMouse and Cheese
- hdu 1078 FatMouse and Cheese
- hdu-1078-FatMouse and Cheese
- HDU 1078 FatMouse and Cheese
- HDU 1078 FatMouse and Cheese
- Hdu 1078 FatMouse and Cheese
- hdu FatMouse and Cheese(dp)
- HDU 1078 FatMouse and Cheese
- HDU 1078 FatMouse and Cheese
- hdu 1078 FatMouse and Cheese
- HDU 1078 FatMouse and Cheese
- HDU 1078 FatMouse and Cheese
- (转)非常完善的Log4net详细说明
- iOS开发笔记之六十八——FRP与RAC介绍(一)
- 显式参数和隐式参数
- Python学习笔记---开发环境搭建
- PostgreSQL查看版本信息
- HDU FatMouse and Cheese
- CSS 的优先级机制[总结]
- 正则表达式学习总结
- 关于项目合并的一些坑 androidStudio项目和Eclipse项目合并
- 【NEUQ】E: ingayass Bio Cards Collecting 【手写链表】or 【 STL list 】
- 学生信息管理系统(c/c++)
- Windows基础——常用的DOS命令
- mysql Mac终端操作
- 解决Sqlserver2008数据库sa密码长度不符合策略要求