题意:和最长滑雪路径一样,

 #include<iostream>
#include<cstdio>
#include<cstring>
#include <cmath>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#define mod=1e9+7;
using namespace std; typedef long long LL;
const int maxn=;
int g[maxn][maxn],vis[maxn][maxn],d[maxn][maxn];
int dir[][]={-,,,,,-,,};
int n,m; int dfs(int x,int y){
if(d[x][y]) return d[x][y];//如果已经搜过这一点,则直接返回,不用再重复计算
int ans=;
for(int i=;i<;i++){ //四个 方向搜
int nx=x+dir[i][];
int ny=y+dir[i][];
if(nx<||nx>n||ny<||ny>m) continue;//越界
if(g[x][y]>g[nx][ny])
ans=max(ans,+dfs(nx,ny));
} if(ans==) return d[x][y]=;
return d[x][y]=ans;
} int main(){
int ncase,r,c;
char s[maxn];
scanf("%d",&ncase);
while(ncase--){
cin>>s;
cin>>n>>m; for(int i=;i<=n;i++)
for(int j=;j<=m;j++) cin>>g[i][j]; memset(d,,sizeof(d));
int tmp=; for(int i=;i<=n;i++){
for(int j=;j<=m;j++)
tmp=max(tmp,dfs(i,j));
}
printf("%s: %d\n",s,tmp);
}
return ;
}

唉= =自己又敲一遍= =运行出来是错的,还对照着以前写的

真是挫爆了= =以后就算不会,也要自己敲一敲 加油--- go---go--go

UVa 10285 Longest Run on a Snowboard【记忆化搜索】的更多相关文章

  1. UVA 10285 Longest Run on a Snowboard(记忆化搜索)

    Problem C Longest Run on a Snowboard Input: standard input Output: standard output Time Limit: 5 sec ...

  2. UVA 10285 - Longest Run on a Snowboard (记忆化搜索+dp)

    Longest Run on a Snowboard Input: standard input Output: standard output Time Limit: 5 seconds Memor ...

  3. UVa 10285 Longest Run on a Snowboard - 记忆化搜索

    记忆化搜索,完事... Code /** * UVa * Problem#10285 * Accepted * Time:0ms */ #include<iostream> #includ ...

  4. UVa 10285 - Longest Run on a Snowboard

    称号:给你一个二维矩阵,找到一个点.每一个可以移动到的位置相邻的上下,求最长单调路径. 分析:贪婪,dp.搜索. 这个问题是一个小样本,我们该怎么办. 这里使用贪心算法: 首先.将全部点依照权值排序( ...

  5. UVA - 10285 Longest Run on a Snowboard (线性DP)

    思路:d[x][y]表示以(x, y)作为起点能得到的最长递减序列,转移方程d[x][y] = max(d[px][py] + 1),此处(px, py)是它的相邻位置并且该位置的值小于(x, y)处 ...

  6. UVA - 10285 Longest Run on a Snowboard(最长的滑雪路径)(dp---记忆化搜索)

    题意:在一个R*C(R, C<=100)的整数矩阵上找一条高度严格递减的最长路.起点任意,但每次只能沿着上下左右4个方向之一走一格,并且不能走出矩阵外.矩阵中的数均为0~100. 分析:dp[x ...

  7. UVA 825 Walking on the Safe Side(记忆化搜索)

      Walking on the Safe Side  Square City is a very easy place for people to walk around. The two-way ...

  8. uva 10581 - Partitioning for fun and profit(记忆化搜索+数论)

    题目链接:uva 10581 - Partitioning for fun and profit 题目大意:给定m,n,k,将m分解成n份,然后依照每份的个数排定字典序,而且划分时要求ai−1≤ai, ...

  9. 【UVA 437】The Tower of Babylon(记忆化搜索写法)

    [题目链接]:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

随机推荐

  1. P1676陶陶吃苹果 - vijos

    描述 curimit知道陶陶很喜欢吃苹果.于是curimit准备在陶陶生日的时候送给他一棵苹果树. curimit准备了一棵这样的苹果树作为生日礼物:这棵苹果树有n个节点,每个节点上有c[i]个苹果, ...

  2. 文本编辑器 markdown

    http://www.cnblogs.com/youxia/p/linux014.html markdown对数学公式的支持http://www.linuxidc.com/Linux/2014-08/ ...

  3. Problem 1014 xxx游戏 暴力+拓扑排序

    题目链接: 题目 Problem 1014 xxx游戏 Time Limit: 1000 mSec Memory Limit : 32768 KB 问题描述 小M最近很喜欢玩XXX游戏.这个游戏很简单 ...

  4. IntelliJ IDEA 14 创建maven项目二

    前言: 在我的idea14使用maven创建web工程文章介绍了如何运用idea14创建maven项目--但有瑕疵,如下: 今天在群里交流才得知起因: 原来一直这样创建的--但结果都一样,均出现上面的 ...

  5. 【HDOJ】【1754】I Hate It

    线段树 这是一道线段树的裸题……带单点修改的RMQ 为什么我会想到写这么一道傻逼题呢?是因为这样……

  6. We Recommend a Singular Value Decomposition

    We Recommend a Singular Value Decomposition Introduction The topic of this article, the singular val ...

  7. 【系统Configmachine.config与自己的应用程序的App.config/Web.Config配置节点重复】解决方法

    自己的应用程序的App.config或Web.Config文件中与系统的C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Configmachine.co ...

  8. tomcat 解析(五)-Tomcat的核心组成和启动过程

    声明:源码版本为Tomcat 6.0.35 前面的文章中介绍了Tomcat的基本配置,每个配置项也基本上对应了Tomcat的组件结构,如果要用一张图来形象展现一下Tomcat组成的话,整个Tomcat ...

  9. DOM对象和JQuery对象的区别

    DOM对象和JQuery对象的区别 jQuery对象和DOM对象使用说明,需要的朋友可以参考下.1.jQuery对象和DOM对象第一次学习jQuery,经常分辨不清哪些是jQuery对象,哪些是 DO ...

  10. DataGridView之行的展开与收缩

    很多数据都有父节点与子节点,我们希望单击父节点的时候可以展开父节点下的子节点数据. 比如一个医院科室表,有父科室与子科室,点击父科室后,在父科室下面可以展现该科室下的所有子科室. 我们来说一下在Dat ...