hdu 1087 zoj 1107 FatMouse and Cheese
来源:互联网 发布:淘宝天猫旗舰店申请 编辑:程序博客网 时间:2024/05/21 09:11
#include <iostream>#include <cstring>#include <string>#include <cstdio>#include <cmath>#include <algorithm>#include <vector>#include <queue>#include <map>#define inf 0x3f3f3f3f#define ll __int64using namespace std;int mp[105][105],d[105][105],n,k;int dx[]={1,-1,0,0};int dy[]={0,0,1,-1};int dfs(int x,int y){ if(d[x][y]) return d[x][y]; int i,j,ret=0,xx,yy,tmp; for(i=0;i<4;i++) { for(j=1;j<=k;j++) { xx=x+j*dx[i]; yy=y+j*dy[i]; if(xx>=0&&xx<n&&yy>=0&&yy<n&&mp[x][y]<mp[xx][yy]) { tmp=dfs(xx,yy); if(ret<tmp) ret=tmp; } } } return d[x][y]=ret+mp[x][y];}int main(){ int i,j; while(scanf("%d%d",&n,&k)&&(n!=-1||k!=-1)) { for(i=0;i<n;i++) for(j=0;j<n;j++) scanf("%d",&mp[i][j]); memset(d,0,sizeof d); printf("%d\n",dfs(0,0)); } return 0;}
0 0
- hdu 1087 zoj 1107 FatMouse and Cheese
- zoj 1107 FatMouse and Cheese
- zoj 1107 FatMouse and Cheese
- zoj 1107 FatMouse and Cheese
- ZOJ 1107 FatMouse and Cheese
- ZOJ 1107 FatMouse and Cheese
- HDU 1107 FatMouse and Cheese
- FatMouse and Cheese HDU
- HDU 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 1078 FatMouse and Cheese
- 详细分析Java中断机制
- OpenMP学习笔记
- poj 3176 Cow Bowling
- 分布式系统协调 ZooKeeper
- javascript_C3数据类型【下】
- hdu 1087 zoj 1107 FatMouse and Cheese
- POSIX 线程详解
- 排序算法一
- 2013蓝桥杯 【初赛试题】 带分数
- poj 2533 && zoj 2136 Longest Ordered Subsequence --- LIS模板
- Java内存解析 栈 堆 常量池
- 用MySQL生成随机整数的方法【随机数】
- Win7环境下VS2010配置Cocos2d-x-2.1.4最新版本的开发环境(亲测)
- poj 1014 && zoj 1149 Dividing --- dfs剪枝