当前位置:网站首页>Memory search acwing 901 skiing
Memory search acwing 901 skiing
2022-07-03 08:51:00 【T_ Y_ F666】
Memory search AcWing 901. skiing
Original link
Algorithm tags
Dynamic programming Memory search
Ideas

Code
#include<bits/stdc++.h>
#define int long long
#define rep(i, a, b) for(int i=a;i<b;++i)
#define Rep(i, a, b) for(int i=a;i>b;--i)
using namespace std;
const int N = 305;
int a[N][N],f[N][N];
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int n, m;
inline int read(){
int s=0,w=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
void put(int x) {
if(x<0) putchar('-'),x=-x;
if(x>=10) put(x/10);
putchar(x%10^48);
}
int dp(int x, int y){
if(f[x][y]!=-1){
return f[x][y];
}
f[x][y]=1;
rep(i, 0, 4){
int xx=x+dx[i], yy=y+dy[i];
if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&a[xx][yy]<a[x][y]){
f[x][y]=max(f[x][y], dp(xx, yy)+1);
}
}
return f[x][y];
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
n=read(), m=read();
rep(i, 1, n+1){
rep(j, 1, m+1){
a[i][j]=read();
}
}
memset(f, -1, sizeof f);
int ans=0;
rep(i, 1, n+1){
rep(j, 1, m+1){
ans=max(ans, dp(i, j));
}
}
printf("%lld", ans);
return 0;
}
Originality is not easy.
Reprint please indicate the source
If it helps you Don't forget to praise and support 
边栏推荐
- Markdown learning
- [rust notes] 06 package and module
- Campus lost and found platform based on SSM, source code, database script, project import and operation video tutorial, Thesis Writing Tutorial
- [rust note] 10 operator overloading
- 第一个Servlet
- [RPC] RPC remote procedure call
- Dom4j traverses and updates XML
- ES6 promise learning notes
- Dealing with duplicate data in Excel with xlwings
- [concurrent programming] synchronization container, concurrent container, blocking queue, double ended queue and work secret
猜你喜欢

Gif remove blank frame frame number adjustment

Binary tree sorting (C language, int type)

Annotations simplify configuration and loading at startup

Graphics_ Learnopongl learning notes

Dom4j遍历和更新XML

Alibaba canal actual combat
![[concurrent programming] working mechanism and type of thread pool](/img/51/d21428a7c95c0a5177e8198742e78c.jpg)
[concurrent programming] working mechanism and type of thread pool

Notes and bugs generated during the use of h:i:s and y-m-d

Campus lost and found platform based on SSM, source code, database script, project import and operation video tutorial, Thesis Writing Tutorial

Mortgage Calculator
随机推荐
【Rust笔记】05-错误处理
Alibaba canal actual combat
Try to reprint an article about CSDN reprint
Dealing with duplicate data in Excel with xlwings
Servlet的生命周期
file_ put_ contents
[concurrent programming] atomic operation CAS
Collection interface
Markdown learning
Concurrent programming (VI) ABA problems and solutions under CAS
[rust notes] 11 practical features
树形DP AcWing 285. 没有上司的舞会
C language student management system based on linked list, super detailed
Development material set
PHP function date (), y-m-d h:i:s in English case
单调栈-503. 下一个更大元素 II
Deeply understand the underlying data structure of MySQL index
Notes on understanding applets 2022/7/3
The method for win10 system to enter the control panel is as follows:
Talking about: is the HashSet set ordered or disordered /hashset set unique, why can we store elements with the same content