800601 skiing
Difficulty level :B; Run time limit :1000ms; Operating space limitation :51200KB; Code length limit :2000000B
Test description

Michael It's not surprising that I like skiing , Because skiing is really exciting . But in order to get speed , The slippery area must be tilted down , And when you get to the bottom of the slope , You have to go uphill again or wait for the lift to pick you up .Michael Want to know the longest landslide in an area . The region is given by a two-dimensional array . Each number in the array represents the height of the point . Here is an example
 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
A person can slide up and down from a certain point to one of the four adjacent points , If and only if the height is reduced . In the example above , A gliding landslide is 24-17-16-1. Of course 25-24-23-...-3-2-1 Longer . in fact , This is the longest one .

Input
The first line of input represents the number of lines in the area R And number of columns C, Here is R That's ok , Each row has C It's an integer , Stands for height h.
Output
Output the length of the longest region .
Input example
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
Output example
25
Other instructions
Data range :1<= R,C<=100,0<=h<=10000.

Answer key : a glance dp.

 #include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstring>
#define PAU putchar(' ')
#define ENT putchar('\n')
using namespace std;
const int maxn=+,inf=1e8;
inline void write(int x);
int f[maxn][maxn],n,m,A[maxn][maxn];
int mx[]={,,-,},my[]={-,,,};
int dp(int x,int y){
if(f[x][y]>=)return f[x][y];f[x][y]=;
for(int d=;d<;d++){
int tx=mx[d]+x,ty=my[d]+y;
if(tx>=&&ty>=&&tx<n&&ty<m&&A[tx][ty]<A[x][y]){
f[x][y]=max(f[x][y],dp(tx,ty)+);
}
}
return f[x][y];
}
inline int read(){
int x=,sig=;char ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')sig=;
for(;isdigit(ch);ch=getchar())x=*x+ch-'';
return sig?x:-x;
}
inline void write(int x){
if(x==){putchar('');return;}if(x<)putchar('-'),x=-x;
int len=,buf[];while(x)buf[len++]=x%,x/=;
for(int i=len-;i>=;i--)putchar(buf[i]+'');return;
}
void init(){
memset(f,-,sizeof(f));
n=read();m=read();
for(int i=;i<n;i++)
for(int j=;j<m;j++)
A[i][j]=read();
int ans=-;
for(int i=;i<n;i++)
for(int j=;j<n;j++)
ans=max(ans,dp(i,j));
write(ans+);
return;
}
void work(){
return;
}
void print(){
return;
}
int main(){init();work();print();return ;}

COJN 0575 800601 More about skiing

  1. tyvj1004 skiing

    describe     trs Like skiing . He came to a ski resort , This ski resort is a rectangle , For simplicity , We use it r That's ok c Column matrix to represent each terrain . To get faster , The taxiing route has to slope down .     For example, the rectangle in the example , You can start from ...

  2. bzoj 2753: [SCOI2012] Skiing and time capsule Label:MST

    Title Description a180285 I like skiing very much . He came to a snow mountain , There are M Two tracks for taxiing and N The intersection of two orbits ( It's also a scenic spot ), And every attraction has a number i(1<=i<=N) And a height Hi.a180285 ...

  3. USACO 2014 JAN Skiing videos

    2.  Skiing videos {silver topic 3} [ Problem description ] The TV schedule for the Winter Olympics includes N (1 <= N <= 150) Programs , Every show has a start and end time . Farmer John has two VCRs , Please calculate the maximum number he can record ...

  4. USACO Skiing lessons

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

  5. Bzoj2753 [SCOI2012] Skiing and time capsule

    2753: [SCOI2012] Skiing and time capsule Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 2282  Solved: 796 Descriptio ...

  6. skiing why WA

    skiing Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 587  Solved: 219 Description Xiao Ming likes skiing , Because skiing is really exciting , But in order to get ...

  7. skiing ( Simple dp)

    Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 81099   Accepted: 30239 Description Mic ...

  8. Code[VS] 2152 Skiing

    Code[VS] 2152 Skiing Title Description  Description trs Like skiing . He came to a ski resort , This ski resort is a rectangle , For simplicity , We use it r That's ok c Column matrix to represent each terrain . To get faster , Taxi ...

  9. E - skiing

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Pract ...

Random recommendation

  1. Error set :js analysis jQuery.post Back to xml And Could not find action or result

    js In the use jQuery.post Go to the background to query data , The return is xml Data stream of format . js Code : var params = ""; params = encodeURI(params); v ...

  2. Arduino Smart car practice learning report

    Arduino Smart car practice learning report Participants : 20135316 Cambridge Wang 20135312 Wu Hanyan 20135319 Juliet One . Background : Single chip microcomputer : The central processing unit CPU( Carry out operations . control ). Ram ...

  3. Wampserver3.0.0 Setting the language to Chinese is invalid

    Open profile "wampmanager.conf", take language Change to chinese, Then choose Chinese from the right language selection . This configuration file has two , Change the... In the first double quotation mark , Don't change the second one without quotation marks ...

  4. #array_parents #parents The difference between

    https://www.drupal.org/node/279246 #array_parents  =>  Must reflect the physical structure of the form   It's down there, down there   It's not true #parents  = ...

  5. iBatis and MyBatis difference

    from   iBatis   To   MyBatis , are you ready ? For those engaged in Java EE For developers ,iBatis It's a familiar persistence layer framework , stay Hibernate.JPA Such a one-stop object ...

  6. Jdbc Business

    package com.j1; import java.sql.Connection; import java.sql.SQLException; import com.mysql.jdbc.Prep ...

  7. Spark Standalone Pattern application development

    author : Past memory  |  Sina weibo : Left hand holding right hand TEL |  Can reprint , However, the original source of the article and the blog address of the author's information and copyright notice must be indicated in the form of hyperlinks :http://www.iteblog.com/ Article title :<Spar ...

  8. js- String function

    js String function JS Built-in function concat Combine two or more characters of text , Returns a new string .var a = "hello";var b = ",world";v ...

  9. JS Preview when uploading pictures

    A picture on a web page can be displayed like this : <img src="http://www.letuknowit.com/images/wg.png"/> It can also be displayed like this :<img s ...

  10. About IWMS The problems encountered in and solutions to

    1. The generated articles are uploaded to the Internet , But after a while, it's back to what it was ? Solution : Upload the page corresponding to template Medium .aspx The page should also be uploaded to the Internet .