当前位置:网站首页>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 
边栏推荐
- Talking about: is the HashSet set ordered or disordered /hashset set unique, why can we store elements with the same content
- [concurrent programming] Table hopping and blocking queue
- Unity interactive water ripple post-treatment
- Slice and index of array with data type
- I made mistakes that junior programmers all over the world would make, and I also made mistakes that I shouldn't have made
- 22-06-27 西安 redis(01) 安装redis、redis5种常见数据类型的命令
- Graphics_ Games101/202 learning notes
- [RPC] RPC remote procedure call
- Convert video to GIF
- Unity Editor Extension - Outline
猜你喜欢

Allocation exception Servlet

Graphics_ Learnopongl learning notes

Character pyramid
![[redis] redis persistent RDB vs AOF (source code)](/img/57/b6a86c49cedee31fc00dc5d1372023.jpg)
[redis] redis persistent RDB vs AOF (source code)

Sending and receiving of request parameters

SQL statement error of common bug caused by Excel cell content that is not paid attention to for a long time

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

Graphics_ Games101/202 learning notes

TP5 multi condition sorting

状态压缩DP AcWing 291. 蒙德里安的梦想
随机推荐
22-05-26 西安 面试题(01)准备
记忆化搜索 AcWing 901. 滑雪
UE4 source code reading_ Bone model and animation system_ Animation compression
Unity editor expansion - controls, layouts
Final review of Database Principles
[concurrent programming] consistency hash
Facial expression recognition based on pytorch convolution -- graduation project
Life cycle of Servlet
[rust note] 10 operator overloading
C language student management system based on linked list, super detailed
Concurrent programming (V) detailed explanation of atomic and unsafe magic classes
【Rust笔记】06-包和模块
producer consumer problem
Alibaba canaladmin deployment and canal cluster Ha Construction
Format - C language project sub file
Monotonic stack -84 The largest rectangle in the histogram
[rust notes] 06 package and module
求组合数 AcWing 885. 求组合数 I
Parameters of convolutional neural network
Unity Editor Extension - event handling