zstu 2553 滑雪
来源:互联网 发布:teambition mac 编辑:程序博客网 时间:2024/05/17 04:51
dfs 就可以了。。
重复的很多要保存。。
#include<stdio.h>#include<string.h>int map[105][105];int way[105][105];int n,m;int max(int g,int h){ return g>h?g:h;}int dfs(int x,int y,int high){ if(x<1||x>n||y<1||y>m||map[x][y]>=high) return 0; if(way[x][y]>=0) return way[x][y]; int step=max(max(dfs(x-1,y,map[x][y]),dfs(x+1,y,map[x][y])),max(dfs(x,y-1,map[x][y]),dfs(x,y+1,map[x][y])))+1; way[x][y]=step; return step;}int main(){ while(scanf("%d%d",&n,&m)!=EOF) { int ans=0; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&map[i][j]); memset(way,-1,sizeof(way)); for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { int test=dfs(i,j,0x3f3f3f3f); ans=max(ans,test); } } printf("%d\n",ans); } return 0;}
0 0
- zstu 2553 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- 滑雪
- Ngnix配置问题,图片的security.limit_extensions问题
- Java对存储过程的调用方法
- debian8.3安装为知笔记的两种方式,ppa源和编译安装,
- Android监听屏幕屏幕锁屏与解锁
- RecyclerView使用资源文件作为分割线divider
- zstu 2553 滑雪
- Ubuntu 下 VPN 自动连接
- HDU 3726 Graph and Queries
- windows基础编程 - 静态库、动态库文件
- RecyclerView虚线分割线
- check the manual that corresponds to your MySQL server version for the right syntax的解决方法
- CString用法大全
- 学习技巧以及学习方法的总结
- GPS 简单实用-GPRMC