当前位置:网站首页>Memory search acwing 901. Skiing
Memory search acwing 901. Skiing
2022-07-27 11:18: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 
边栏推荐
- Background color style modification on table hover in antd
- Taishan Office Technology Lecture: scaling and opening files
- Redis+caffeine two-level cache enables smooth access speed
- Regular form form judgment
- Remember not to copy your group work, students. Fortunately, you only passed two questions. Don't have an accident
- Ansible
- SQL Server2000数据库错误
- 求组合数 AcWing 889. 满足条件的01序列
- Instructions for mock platform
- 2022牛客多校训练(3)A-Ancestor 题目翻译
猜你喜欢

Real time development platform construction practice, in-depth release of real-time data value - 04 live broadcast review

Longest ascending subsequence model acwing 482. Chorus formation

Shortest moving distance and entropy of morphological complex

熵与形态的非递进现象

Longest ascending subsequence model acwing 1012. Sister Cities

Derive the detailed expansion of STO double center kinetic energy integral

背包模型 AcWing 1022. 宠物小精灵之收服

The influence of the number of non-zero values in the picture on Classification

Introduction to software vulnerability analysis (I)

如何组装一个注册中心
随机推荐
Shock simulation of engine mounting system transient modal dynamic analysis and response spectrum analysis
神经网络学习笔记
2022牛客多校 (3)J.Journey
Regular form form judgment
栈 AcWing 3302. 表达式求值
Analysis of C language pointer function and function pointer
Cancer DDD
The second method of calculating overlapping integral
【着色器实现Shake随机摇动效果_Shader效果第十篇】
The longest ascending subsequence model acwing 1016. The sum of the largest ascending subsequence
洛谷P1441 砝码称重
Wenzhou University X kangaroo cloud: how to "know well" in the construction of higher talent education
How to build a real-time development platform to deeply release the value of enterprise real-time data?
parsel的使用
博弈论 AcWing 893. 集合-Nim游戏
Solutions to errors in tensorflow operation
最长上升子序列模型 AcWing 1010. 拦截导弹
Knapsack model acwing 1024. Packing problem
中国剩余定理 AcWing 204. 表达整数的奇怪方式
IO流_字符流、IO流小结、IO流案例总结