題目鏈接:http://poj.org/problem?id=1088

題意:中文題誒~

思路:dfs,不過直接dfs因該會超時,那我們給他加個記錄路徑就好了...

代碼:

 #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std; const int MAXN=1e2+;
int dp[MAXN][MAXN], mp[MAXN][MAXN];
int dir[][]={, , , -, , , -, };
int n, m, fx, fy; int dfs(int x, int y){
if(dp[x][y]) return dp[x][y];
for(int i=; i<; i++){
fx=x+dir[i][];
fy=y+dir[i][];
if(fx>=&&fx<n&&fy>=&&fy<m){
if(mp[fx][fy]<mp[x][y]){
int cnt=dfs(fx, fy);
if(dp[x][y]<cnt+){
dp[x][y]=cnt+;
}
}
}
}
return dp[x][y];
} int main(void){
while(cin >> n >> m){
int ans=;
memset(dp, , sizeof(dp));
for(int i=; i<n; i++){
for(int j=; j<m; j++){
cin >> mp[i][j];
}
}
for(int i=; i<n; i++){
for(int j=; j<m; j++){
int cnt=dfs(i, j);
ans=max(ans, cnt);
}
}
cout << ans+ << endl;
}
return ;
}

最新文章

  1. 使用MATLAB对图像处理的几种方法(上)
  2. plist文件的读取和xib加载cell
  3. GUID 全局统一标识符的介绍
  4. python代码编程规范
  5. [原创]谷歌插件 - YE搜图助手(YeImageFinder)
  6. Android Service AIDL 远程调用服务 【简单音乐播放实例】
  7. JS浮点类型计算
  8. Oracle EBS-SQL (WIP-4):检查检查成品标准作业是否勾选&quot;固定&quot;标识.sql
  9. LeetCode OJ 82. Remove Duplicates from Sorted List II
  10. android AlarmManager讲解
  11. 单片机stm32小白入门级学习路线“图”
  12. Exploit-Exercises nebule 旅行日志(三)
  13. SqlServer误删数据恢复
  14. Visual Studio 2015编译Lua 5.3.4遇到的坑
  15. genimage.cfg.template hacking
  16. 实验8 LCD8*8点阵
  17. 解决Mysql中文乱码问题的方案
  18. create sequence
  19. 深入理解JVM一垃圾回收算法
  20. Delphi 中的自动释放策略

热门文章

  1. C语言“快速排序”函数写法
  2. hihocoder 在线测试 补提交卡 (Google)
  3. Zookeeper原理与Curator使用
  4. python列表切片
  5. python的tkinter对话框
  6. javascript(9)
  7. CC通信软件list
  8. spark源码笔记
  9. AtCoder Beginner Contest 102
  10. 51nod_1236_序列求和 V3 _组合数学