poj 1088
来源:互联网 发布:nginx 配置路径 编辑:程序博客网 时间:2024/06/08 04:04
记忆化搜索
因为写错边界 错了n次不知道怎么回事
#include <iostream>#include <algorithm>#include <queue>#include <cstring>#include <cstdio>#include <vector>#include <string>#include <iterator>#include <cmath>#include <deque>#include <stack>#include <cctype>#include <iomanip>using namespace std;typedef long long ll;typedef long double ld;const int N = 120;const int INF = 0xfffffff;const double EPS = 1e-8;const ll MOD = 1e9 + 7;const ld PI = acos (-1.0);#define INFL 0x7fffffffffffffffLL#define met(a, b) memset(a, b, sizeof(a))#define put(a) cout << setiosflags(ios::fixed) << setprecision(a)int m, n, a[N][N], dp[N][N];int dir[4][2] = {0, 1, 1, 0, 0, -1, -1, 0};int solve (int x, int y);int main (){ while (cin >> m >> n) { met (dp, 0); for (int i=0; i<m; i++) for (int j=0; j<n; j++) cin >> a[i][j]; int ans = 0; for (int i=0; i<m; i++) for (int j=0; j<n; j++) ans = max (ans, solve (i, j)); cout << ans << endl; } return 0;}int solve (int x, int y){ if (dp[x][y]) return dp[x][y]; int k = 0; for (int i=0; i<4; i++) { int x1 = x + dir[i][0], y1 = y + dir[i][1]; if (x1 >= 0 && x1 < m && y1 >= 0 && y1 < n && a[x1][y1] < a[x][y]) k = max (k, solve(x1, y1)); } return dp[x][y] = k + 1;}
0 0
- POJ 1088
- POJ 1088
- poj 1088
- poj 1088
- POJ 1088
- poj 1088
- poj 1088
- poj 1088
- poj 1088
- poj 1088
- poj 1088
- poj--1088
- POJ 1088
- poj 1088
- poj 1088
- POJ 1088
- poj 1088
- POJ 1088
- 内存管理和ARC
- 9.1 ChocolatesByNumbers
- Hadoop性能优化点小结
- 2015多益网络实习生招聘一题解析3
- Ant入门案例-打包Web程序并发布
- poj 1088
- 自定义Cordova插件、Ionic插件开发
- [BZOJ1996]HNOI2010合唱队|DP
- Cocos2d-JS中使用CocosStudio资源——登录界面
- hdu 1422 重温世界杯
- easyui和thinkphp整合的分页功能
- 十期讨论反思
- EL表达式与jQuery
- 基于hibernate的泛型Dao框架