POJ 1088 滑雪——DP
来源:互联网 发布:做网站必备软件 编辑:程序博客网 时间:2024/04/24 06:43
记忆化搜索
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int dx[] = {-1, 1, 0, 0};const int dy[] = {0, 0, -1, 1};int m, n, a[110][110], dp[110][110];int dfs(int x, int y) { if (dp[x][y] != -1) return dp[x][y]; int ans = 0; for (int i = 0; i < 4; i++) { int xx = x + dx[i], yy = y + dy[i]; if (1 <= xx && xx <= m && 1 <= yy && yy <= n && a[xx][yy] < a[x][y]) { ans = max(ans, dfs(xx, yy)); } } return dp[x][y] = ans + 1;}int main(){ while (~scanf("%d %d", &m, &n)) { for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { scanf("%d", &a[i][j]); } } memset(dp, -1, sizeof(dp)); int ans = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { ans = max(ans, dfs(i, j)); } } printf("%d\n", ans); } return 0;}
阅读全文
1 0
- POJ 1088 滑雪——DP
- poj 1088 滑雪(DP)
- POJ 1088 滑雪 DP
- poj 1088 滑雪 (DP)
- poj 1088 滑雪 DP
- POJ 1088 滑雪 DP
- POJ 1088-滑雪(dp)
- poj 1088 滑雪DP
- POJ 1088 滑雪 DP
- POJ-----1088---滑雪DP
- 【DP】POJ 1088 滑雪
- poj 1088 滑雪【DP备忘录】
- POJ 1088 DP+深搜 滑雪
- poj 1088 经典dp 滑雪
- POJ 1088 滑雪(DP)
- POJ 1088 滑雪 DP + dfs
- POJ 1088 滑雪(dp)
- POJ 1088 滑雪(DFS+DP)
- 菜鸟的myeclipse快捷之路
- python 经典类和新式类
- Ajax简单解析
- python显示图片
- 学习记录(8)
- POJ 1088 滑雪——DP
- python 公有属性和私有属性
- Codeforces Round #428 (Div. 2) D
- hdu 4944 FSF’s game 数学(公因子)+递推公式
- test ATL OCX by vs2015
- 面试运维
- iptables: No config file. [WARNING]!
- nodejs-socket网络编程
- 关于在Aptana Studio中编写js效果在浏览器中的刷新问题,光标变黑色矩形问题