poj(1088)
来源:互联网 发布:身份证拍照软件 编辑:程序博客网 时间:2024/05/16 04:25
题目:http://poj.org/problem?id=1088
记忆化搜索,不然会超时的,这种方式避免了重复计算,所以效率要高一些
#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#define maxn 105using namespace std;int r,c;int map[maxn][maxn];int dp[maxn][maxn];int f(int x, int y){ if(dp[x][y] != 0) returndp[x][y]; int temp = 0; if(map[x][y] > map[x + 1][y]) temp = max(temp , f(x + 1,y)); if(map[x][y] > map[x][y + 1]) temp = max(temp , f(x , y + 1)); if(map[x][y] > map[x - 1][y]) temp = max(temp , f(x - 1, y)); if(map[x][y] > map[x][y - 1]) temp = max(temp , f(x , y - 1)); dp[x][y] = temp + 1; return dp[x][y];}int main(){ int i,j; while(~scanf("%d%d",&r,&c)){ int ans =0; memset(map, 0x3f, sizeof(map)); for(i =1;i <=r; i++) for(j = 1;j <= c;j++) scanf("%d",map[i] + j); memset(dp, 0,sizeof(dp)); for(i =1;i <=r;i++) for(j = 1;j <= c;j++) ans = max(ans , f(i , j)); printf("%d\n",ans); } return 0;}
0 0
- POJ 1088(滑雪)
- poj(1088)
- 滑雪(POJ-1088)
- POJ 1088 滑雪(DP)
- POJ 1088 滑雪(dp)
- poj - 1088 - 滑雪(dp)
- POJ 1088 滑雪 (dp)
- POJ 1088 滑雪(DP)
- POJ 1088 滑雪 (深搜)
- POJ 1088 滑雪(dp)
- poj 1088 滑雪(beta)
- POJ 1088 滑雪 (DP)
- H-滑雪(POJ 1088)
- POJ 1088 滑雪(dp)
- POJ 1088
- POJ 1088
- poj 1088
- poj 1088
- hoj 1999
- HOJ 1760 (最长上升子序列)
- hoj(1797)
- hoj 1440 bfs
- oracle恢复10分钟之前的数据
- poj(1088)
- poj3461
- usaco traini 5.2.2 Electric Fences 题解
- hdu 3746
- poj(2752)
- poj2406
- ADF自定义控件例子
- hoj (2275)树状数组
- hdu(4325)