当前位置:网站首页>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 
边栏推荐
- 【Rust 笔记】13-迭代器(上)
- 使用dlv分析golang进程cpu占用高问题
- [rust notes] 02 ownership
- createjs easeljs
- 基于SSM的校园失物招领平台,源码,数据库脚本,项目导入运行视频教程,论文撰写教程
- Annotations simplify configuration and loading at startup
- How to delete CSDN after sending a wrong blog? How to operate quickly
- Dom4j遍历和更新XML
- UE4 source code reading_ Bone model and animation system_ Animation process
- Binary tree sorting (C language, char type)
猜你喜欢
随机推荐
Unity editor expansion - window, sub window, menu, right-click menu (context menu)
Unity editor expansion - the design idea of imgui
Campus lost and found platform based on SSM, source code, database script, project import and operation video tutorial, Thesis Writing Tutorial
22-06-27 Xian redis (01) commands for installing five common data types: redis and redis
【Rust 笔记】11-实用特型
Really explain the five data structures of redis
Solution of 300ms delay of mobile phone
[set theory] order relation (total order relation | total order set | total order relation example | quasi order relation | quasi order relation theorem | bifurcation | quasi linear order relation | q
too many open files解决方案
单调栈-84. 柱状图中最大的矩形
Animation_ IK overview
TP5 order multi condition sort
Facial expression recognition based on pytorch convolution -- graduation project
状态压缩DP AcWing 91. 最短Hamilton路径
22-05-26 西安 面试题(01)准备
MySQL index types B-tree and hash
Markdown learning
高斯消元 AcWing 883. 高斯消元解线性方程组
DOM 渲染系统(render mount patch)响应式系统
[rust notes] 08 enumeration and mode








