题目

又一道可以称之为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)的更多相关文章

  1. poj 1088 动态规划+dfs(记忆化搜索)

    滑雪 Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Description Mi ...

  2. POJ 1088 滑雪(记忆化搜索+dp)

    POJ 1088 滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 107319   Accepted: 40893 De ...

  3. 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. ...

  4. UVA - 11324 The Largest Clique 强连通缩点+记忆化dp

    题目要求一个最大的弱联通图. 首先对于原图进行强连通缩点,得到新图,这个新图呈链状,类似树结构. 对新图进行记忆化dp,求一条权值最长的链,每一个点的权值就是当前强连通分量点的个数. /* Tarja ...

  5. cf835(预处理 + 记忆化dp)

    题目链接: http://codeforces.com/contest/835/problem/D 题意: 定义 k 度回文串为左半部分和右半部分为 k - 1 度的回文串 . 给出一个字符串 s, ...

  6. cf779D(记忆化dp)

    题目链接: http://codeforces.com/problemset/problem/799/D 题意: 给出两个矩阵边长 a, b, 和 w, h, 以及一个 c 数组, 可选择 c 数组中 ...

  7. Codeforces1107E Vasya and Binary String 记忆化dp

    Codeforces1107E 记忆化dp E. Vasya and Binary String Description: Vasya has a string \(s\) of length \(n ...

  8. POJ 1088 滑雪 记忆化DP

    滑雪 Time Limit: 1000MS   Memory Limit: 65536K       Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度 ...

  9. POJ 1088 滑雪(记忆化搜索)

    滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 92384   Accepted: 34948 Description ...

随机推荐

  1. LeetCode 290. Word Pattern (词语模式)

    Given a pattern and a string str, find if str follows the same pattern. Here follow means a full mat ...

  2. Codeforces--622A--Infinite Sequence(数学)

     Infinite Sequence Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:26214 ...

  3. 【SCOI 2011】 糖果

    [题目链接] 点击打开链接 [算法] 当x = 1时,连边(a,b,0)和(b,a,0) 当x = 2时,连边(a,b,1) 当x = 3时,连边(b,a,0) 当x = 4时,连边(b,a,1) 当 ...

  4. bzoj2253

    cdq分治+dp 看见三维偏序是cdq,互相包含是最长上升子序列 这个代码是错的 交了两份代码,发现手动出数据是不一样的... 不调了 #include<bits/stdc++.h> us ...

  5. 特征变化--->特征向量中部分特征到类别索引的转换(VectorIndexer)

    VectorIndexer: 倘若所有特征都已经被组织在一个向量中,又想对其中某些单个分量进行处理时,Spark ML提供了VectorIndexer类来解决向量数据集中的类别性特征转换. 通过为其提 ...

  6. Coursera Algorithms week4 基础标签表 练习测验:Check if a binary tree is a BST

    题目原文: Given a binary tree where each 

  7. ural 1017. Staircases(dp)

    http://acm.timus.ru/problem.aspx?space=1&num=1017 题意:有n块砖,要求按照严格递增的个数摆放成楼梯,求楼梯的摆放种类数. 思路:状态转移方程: ...

  8. Akka源码分析-Remote-网络链接生命周期

    remote模式下,网络链接的生命周期往往影响着对应Actor的生命周期,那么网络链接的生命周期是怎么样的呢? 每一个与远程系统的链路都是四个状态之一:空闲.活跃.被守护.被隔离.远程系统的某个地址没 ...

  9. Oracle group by分组拼接字符串

    select wm_concat(id),depon  from test_1  group by depon

  10. 1.1输出“hello,world”

    #include<iostream> using namespace std; int main() { cout<<"Hello, World!"< ...