POJ 1088 滑雪(简单的记忆化dp)
又一道可以称之为dp的题目,虽然看了别人的代码,但是我的代码写的还是很挫,,,,,,
//看了题解做的简单的记忆化dp #include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
int mp[][],dp[][];
int xx[]={,-,,};
int yy[]={,,,-};
int n,m;
int dfs(int x,int y)
{
int ans=;
if(dp[x][y])return dp[x][y];
for(int i=;i<;i++)
{
int dx=xx[i]+x,dy=yy[i]+y;
if(dx>=&&dy>=&&dx<n&&dy<m)
{
if(mp[dx][dy]>mp[x][y])
ans=max(ans,+dfs(dx,dy));
}
}
dp[x][y]=ans;
return ans;
}
int main()
{ while(scanf("%d%d",&n,&m)!=EOF){
for(int i=;i<n;i++){
for(int j=;j<m;j++){
scanf("%d",&mp[i][j]);
dp[i][j]=;
}
}
for(int i=;i<n;i++)
for(int j=;j<m;j++)
dp[i][j]=dfs(i,j);
int maxx=;
for(int i=;i<n;i++)
for(int j=;j<m;j++)
maxx=maxx>dp[i][j]? maxx:dp[i][j];
printf("%d\n",maxx);
}
return ;
}
POJ 1088 滑雪(简单的记忆化dp)的更多相关文章
- poj 1088 动态规划+dfs(记忆化搜索)
滑雪 Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Description Mi ...
- POJ 1088 滑雪(记忆化搜索+dp)
POJ 1088 滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 107319 Accepted: 40893 De ...
- Google Code Jam 2009, Round 1C C. Bribe the Prisoners (记忆化dp)
Problem In a kingdom there are prison cells (numbered 1 to P) built to form a straight line segment. ...
- UVA - 11324 The Largest Clique 强连通缩点+记忆化dp
题目要求一个最大的弱联通图. 首先对于原图进行强连通缩点,得到新图,这个新图呈链状,类似树结构. 对新图进行记忆化dp,求一条权值最长的链,每一个点的权值就是当前强连通分量点的个数. /* Tarja ...
- cf835(预处理 + 记忆化dp)
题目链接: http://codeforces.com/contest/835/problem/D 题意: 定义 k 度回文串为左半部分和右半部分为 k - 1 度的回文串 . 给出一个字符串 s, ...
- cf779D(记忆化dp)
题目链接: http://codeforces.com/problemset/problem/799/D 题意: 给出两个矩阵边长 a, b, 和 w, h, 以及一个 c 数组, 可选择 c 数组中 ...
- Codeforces1107E Vasya and Binary String 记忆化dp
Codeforces1107E 记忆化dp E. Vasya and Binary String Description: Vasya has a string \(s\) of length \(n ...
- POJ 1088 滑雪 记忆化DP
滑雪 Time Limit: 1000MS Memory Limit: 65536K Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度 ...
- POJ 1088 滑雪(记忆化搜索)
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 92384 Accepted: 34948 Description ...
随机推荐
- scikit-learn:4.7. Pairwise metrics, Affinities and Kernels
參考:http://scikit-learn.org/stable/modules/metrics.html The sklearn.metrics.pairwise submodule implem ...
- ios oc调用swift framework
1.oc 调用swift /*oc调用swift, project name为DeomOC: 1.oc工程DemoOC中显式创建一个swift文件,生成DemoOC-Bridging-Header.h ...
- mysql学习笔记:存储过程
use test; drop table if exists t8; CREATE TABLE t8(s1 INT,PRIMARY KEY(s1)); drop procedure if exists ...
- 【Ubuntu】莫名其妙硬盘空间满了
一个个翻找,发现是 ~/.cache 占用了很多空间,遂删去其中内容 没有什么负面影响,删掉之后节省了许多空间
- CMDBuild安装及webservice接口的获取
近期项目组之前一直使用的OneCMDB出现了问题,在增删改数据时异常的慢.于是考虑能否够优化OneCMDB.由于本人水平有限,对OneCMDB进行代码级别的优化临时还有点难度.于是就对现有的其它开源C ...
- Batch 拷贝远程机器文件到本机指定目录下
net use * /del /yesNET USE Y: \\远程机IP\d$ 登录密码 /user:domain\登录用户 set sourcePath="Y:\DOAutomatio ...
- windowActionModeOverlay
windowActionModeOverlay: android:windowActionModeOverlay=“true|false” : actionmode 弹出时覆盖部分布局 若 ...
- YTU 2774: Prepare for CET6
2774: Prepare for CET6 时间限制: 1 Sec 内存限制: 128 MB 提交: 40 解决: 37 题目描述 Hard to force the CET4&6 is ...
- mvn scope (转)
策略一: 对于容器提供的(如:servlet-api-2.3等)和测试需要时的(如:junit-3.81等),可以直接在pom.xml中去掉. maven的dependency中有一个tag是< ...
- 【转载】深入理解Linux文件系统
1.rm-rf删除目录里的文件后,为什么可以恢复? 首先创建一个空目录test,目录的blocksize为4096字节 为了空目录还是4096?首先,目录的大小取决它所包含的文件的inode(访问 ...