思路:
dp的思想,記憶化搜尋
**1:
#include using namespace std;
typedef mapmii;
typedef vectorvi;
typedef pairpii;
//狀態轉移方程 d[i][j] = max(d[i-1][j],d[i+1][j],d[i][j-1],d[i][j+1]) + 1;
const int dx[4] = ;
const int dy[4] = ;
int n, m;
int max, ans;
int d[110][110];
int f[110][110];//記錄
int dp(int x, int y)
f[x][y] = ans + 1;//其周圍四個方向的最大值+這個方向到其本身的一步,狀態轉移方程
return f[x][y];
}int main()
printf("%d", max);
return 0;
}
**2:
哈哈時隔半年再做這道題,做一下**風格的對比~
#include #include #include #include //dp[i][j] = max+1;
using namespace std;
const int maxn = 100+5;
int n, m;
int dx = ;
int dy = ;
int dp[maxn][maxn];
int my_map[maxn][maxn];
int dp(int x, int y)
return dp[x][y] = re + 1;
}int main(){
int ans = 0;
scanf("%d%d", &n, &m);
for(int i=0; i
POJ 1088 滑雪 記憶化搜尋
滑雪 time limit 1000ms memory limit 65536k total submissions 79619 accepted 29637 description michael喜歡滑雪百這並不奇怪,因為滑雪的確很刺激。可是為了獲得速度,滑的區域必須向下傾斜,而且當你滑到坡底,你...
POJ 1088 滑雪 記憶化搜尋
description michael喜歡滑雪百這並不奇怪,因為滑雪的確很刺激。可是為了獲得速度,滑的區域必須向下傾斜,而且當你滑到坡底,你不得不再次走上坡或者等待公升降機來載你。michael想知道載乙個區域中最長底滑坡。區域由乙個二維陣列給出。陣列的每個數字代表點的高度。下面是乙個例子 1 2 ...
POJ 1088 滑雪 記憶化搜尋
滑雪 time limit 1000ms memory limit 65536k total submissions 84463 accepted 31618 description michael喜歡滑雪百這並不奇怪,因為滑雪的確很刺激。可是為了獲得速度,滑的區域必須向下傾斜,而且當你滑到坡底,你...