滑雪

Time Limit: 1000ms
Memory Limit: 65536KB
 
This problem will be judged on PKU. Original ID: 1088
64-bit integer IO format: %lld      Java class name: Main
 
Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激。可是为了获得速度,滑的区域必须向下倾斜,而且当你滑到坡底,你不得不再次走上坡或者等待升降机来载你。Michael想知道载一个区域中最长底滑坡。区域由一个二维数组给出。数组的每个数字代表点的高度。下面是一个例子 

 1  2  3  4 5

16 17 18 19 6

15 24 25 20 7

14 23 22 21 8

13 12 11 10 9


一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。

Input

输入的第一行表示区域的行数R和列数C(1 <= R,C <= 100)。下面是R行,每行有C个整数,代表高度h,0<=h<=10000。

 

Output

输出最长区域的长度。

 

Sample Input

5 5
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
 

Sample Output

25
 

Source

 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <climits>
#include <ctype.h>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
int rows,cols;
int table[][],rec[][];
int solve(int x,int y,int height){
if(x < || y < || x >= rows || y >= cols || table[x][y] <= height)
return ;
if(rec[x][y]) return rec[x][y];
rec[x][y] = max(rec[x][y],solve(x-,y,table[x][y]));
rec[x][y] = max(rec[x][y],solve(x+,y,table[x][y]));
rec[x][y] = max(rec[x][y],solve(x,y+,table[x][y]));
rec[x][y] = max(rec[x][y],solve(x,y-,table[x][y]));
return ++rec[x][y];
}
int main(){
int i,j,mx,temp;
scanf("%d %d",&rows,&cols);
for(i = ; i < rows; i++){
for(j = ; j < cols; j++){
scanf("%d",table[i]+j);
rec[i][j] = ;
}
}
for(mx = i = ; i < rows; i++){
for(j = ; j < cols; j++){
temp = solve(i,j,INT_MIN);
if(temp > mx) mx = temp;
}
}
printf("%d\n",mx);
return ;
}

BNUOJ 1207 滑雪的更多相关文章

  1. BNUOJ 23905 滑雪

    滑雪 Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on UESTC. Original ID: 13096 ...

  2. tyvj1004 滑雪

    描述     trs喜欢滑雪.他来到了一个滑雪场,这个滑雪场是一个矩形,为了简便,我们用r行c列的矩阵来表示每块地形.为了得到更快的速度,滑行的路线必须向下倾斜.    例如样例中的那个矩形,可以从某 ...

  3. bzoj 2753: [SCOI2012] 滑雪与时间胶囊 Label:MST

    题目描述 a180285非常喜欢滑雪.他来到一座雪山,这里分布着M条供滑行的轨道和N个轨道之间的交点(同时也是景点),而且每个景点都有一编号i(1<=i<=N)和一高度Hi.a180285 ...

  4. USACO 2014 JAN 滑雪录像

    2. 滑雪录像{silver题3} [问题描述] 冬奥会的电视时刻表包含N (1 <= N <= 150)个节目,每个节目都有开始和结束时间.农民约翰有两台录像机,请计算他最多可以录制多少 ...

  5. USACO 滑雪课程

    #include<cstdio> #include<iostream> using namespace std; int T,S,N,maxd; ],lv[],next[],f ...

  6. BNUOJ 52325 Increasing or Decreasing 数位dp

    传送门:BNUOJ 52325 Increasing or Decreasing题意:求[l,r]非递增和非递减序列的个数思路:数位dp,dp[pos][pre][status] pos:处理到第几位 ...

  7. Bzoj2753 [SCOI2012]滑雪与时间胶囊

    2753: [SCOI2012]滑雪与时间胶囊 Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 2282  Solved: 796 Descriptio ...

  8. 滑雪 why WA

    滑雪 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 587  Solved: 219 Description 小明喜欢滑雪,因为滑雪的确很刺激,可是为了获 ...

  9. bnuoj 24251 Counting Pair

    一道简单的规律题,画出二维表将数字分别相加可以发现很明显的对称性 题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=24251 #include< ...

随机推荐

  1. [转]Android应用自动更新功能的代码实现

    本文转自:http://www.cnblogs.com/coolszy/archive/2012/04/27/2474279.html 由于Android项目开源所致,市面上出现了N多安卓软件市场.为 ...

  2. 接口文档管理工具rap

    git地址:  https://github.com/thx/RAP wiki : https://github.com/thx/RAP/wiki/home_cn 视频教程: http://thx.g ...

  3. [BZOJ2434][Noi2011]阿狸的打字机 AC自动机+树状数组+离线

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2434 题目中这种多个串匹配的问题,一下子就想到了AC自动机.然后发现如果要建立AC自动机, ...

  4. link标签的media属性的用法

    <link rel=stylesheet" type="text/css" href="print.css" media="scree ...

  5. SQL Server 2008 转换为 SQL 2005 数据库 脚本生成

    Tips: 本文讨论如何把数据库从SQL Server 2008版本降低到2005,因为在本地开发是以SQL Server 2008 Express Edition版本进行的,而主机提供商现在提供的M ...

  6. Android 8.0 NotificationChannel 采坑实例

    Android O 上Notification的新特性: 通知通道功能 1. 简介: 通知通道功能使开发者管理自己应用的通知成为一个组或者一个通道,用户可以通过通知通道完成设置通知,如:阻止所有通知, ...

  7. andorid 向上滑动控制标题栏显示

    要实现这样的功能,原理不难,监听滑动距离再设置标题栏的透明度 下面是监听一个带头view的list实现核心代码: mbar是标题栏 mListView.setOnScrollListener(new ...

  8. eclipse版本要求修改

    eclipse要求打开的是java1.6,而安装的是java1.7,这个时候需要修改配置 找到JAVA的安装路径, 点击前往-电脑-资源库-Java-javaVCirtualMachines-...- ...

  9. 在hibernate框架中配置显示sql语句

    使用Hibernate的框架开发时,可在Hibernate.cfg.xml中加上 <property name="hibernate.show_sql">true< ...

  10. C# Process.Start方法

    System.Diagnostics.Process.Start(); 主要功能: 1.打开某个链接网址(弹窗). 2.定位打开某个文件目录. 3.打开系统特殊文件夹,如“控制面板”等. Proces ...