当前位置:网站首页>P1434 [SHOI2002] 滑雪 (记忆化搜索
P1434 [SHOI2002] 滑雪 (记忆化搜索
2022-06-13 07:18:00 【lcxdz】
#include<bits/stdc++.h>
using namespace std;
const int N=110;
int mp[N][N];
int ans[N][N];
int dx[]={
1,-1,0,0};
int dy[]={
0,0,1,-1};
int n,m;
int dfs(int x,int y){
// cout<<ans[i][j]<<"\n";
int mx=0;
if(ans[x][y]!=0)return ans[x][y];
ans[x][y]=1;
for(int i=0;i<4;i++){
int nx=x+dx[i];
int ny=y+dy[i];
if(nx<=n&&nx>=1&&ny<=m&&ny>=1&&mp[nx][ny]<mp[x][y]){
ans[x][y]=max(ans[x][y],dfs(nx,ny)+1);
}
}
return ans[x][y];
}
int main(){
cin>>n>>m ;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>mp[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
// cout<<"--\n";
dfs(i,j);
}
}
int mx=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
// cout<<ans[i][j]<<" ";
mx=max(mx,ans[i][j]);
}
// cout<<"\n";
}
cout<<mx<<"\n";
return 0;
}
边栏推荐
- Tidb index optimization
- Ansible PlayBook的中清单变量优先级分析及清单变量如何分离总结
- Tidb grafana reverse proxy
- Department store center supply chain management system
- 关于c#委托、事件相关问题
- . Net code to implement get request and post request
- FSM状态机
- It's called the next generation monitoring system. Let's see how awesome it is
- 【ViveFocus使用WaveVR插件获取手柄操作事件】
- 检测循环数“142857“
猜你喜欢

RT thread simulator lvgl control: slider control

Detailed Mr Atlas of hip joint (Reprinted)

Detailed description of drawing ridge plot, overlapping densities of overlapping kernel density estimation curve, facetgrid object and function sns Kdeplot, function facetgrid map

基于SSM实现水果商城批发平台

玄武云科技通过上市聆讯:业绩波动明显,陈永辉等三人为控股股东

对绘制丘岭密度图ridge plot的详细说明、重叠核密度估计曲线overlapping densities、FacetGrid对象、函数sns.kdeplot、函数FacetGrid.map

redis-5. Redis' RDB, fork, copyonwrite, AOF, RDB & AOF are mixed

redis-7. Redis master-slave replication, cap, Paxos, cluster sharding cluster 02

Tidb grafana reverse proxy

不间断管理设计
随机推荐
[cloud native | kubernetes] kubernetes configuration
June 12, 2022: if there are n*n pieces in an n*n square chessboard, each grid can have exactly one piece. But now some pieces are gathered on a grid, such as 2030100300. The above two-dimensional arra
The password does not take effect after redis is set
RT-Thread 模拟器 simulator LVGL控件:button 按钮事件
Calculate running total / running balance
oracle问题,字段里面的数据被逗号隔开,取逗号两边数据
Br tool backup recovery
Sorting of numbers and strings
Tidb execution plan -- II
量化框架backtrader之一文读懂Analyzer分析器
【转】FPGA面试题
Simple understanding of basic language of C language
Is it safe for Hangzhou Securities to open an account?
在 localStorage 中上传和检索存储图像
RT thread simulator lvgl control: button button style
理财产品连续几天收益都是零是怎么回事?
关于#数据库#的问题:PGADMIN4 编辑sql窗口问题
基于SSM实现水果商城批发平台
How to write an amazing design document?
redis-2. Redis string type & bitmap