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

 #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. java url中文参数乱码问题

    http://www.blogjava.net/jerry-zhaoj/archive/2009/07/16/286993.html 转 JAVA 中URL链接中文参数乱码的处理方法JAVA 中URL ...

  2. MySQL数据库错误server_errno=2013的解决

    MySQL数据库错误server_errno=2013的解决 一组MySQL复制环境中的Master意外掉电,重启后Master运行正常,但该复制环境中的其它slave端,Error Log中却抛出的 ...

  3. 本地虚拟机中匿名ftp上传文件失败的问题

    在10.10.50.230中新建了一个匿名的ftp服务器,结果在10.10.50.241中上传文件时提示: local: README.txt remote: /var/ftp/pub/upload ...

  4. WinForm点击按钮在对应的panel里画图

    panel在form1里,button在form1上方,panel在下面. 主要是在button1的click时间获取panel的画笔. 下面的不行,在panel里获取画笔,然后传到button1,根 ...

  5. HTML中动态图片切换JQuery实现

    相信很多同学都注意到了,各大新闻或者娱乐网站都含有动态图片切换,那个漂亮的感觉让刚刚学习html的人,都非常好奇和心动.那下面就让我们看一下到底如何实现动态图片切换呢?看一下百度贴吧的效果图吧~ // ...

  6. Consumer Client Re-Design (翻译)

    注:0.9版本Kafka的一个重大改变就是consumer和producer API的重新设计. 这篇Kafka的文档大致介绍了对于consumer API重新设计时想要实现的功能.0.9版本的确实现 ...

  7. What are Scopes?

    scope is an object that refers to the application model. It is an execution context for expressions. ...

  8. javascript中li标签的排序和数组sort的用法

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...

  9. Pycharm中的实用功能(网上看到的,感觉还不错)

    实时比较 PyCharm 对一个文件里你做的改动保持实时的跟踪,通过在编辑器的左侧栏显示一个蓝色的标记.这一点非常方便,我之前一直是在Eclipse里面用命令“Compare against HEAD ...

  10. Java实现二维码QRCode的编码和解码

    涉及到的一些主要类库,方便大家下载: 编码lib:Qrcode_swetake.jar   (官网介绍-- http://www.swetake.com/qr/index-e.html) 解码lib: ...