ACM: 动态规划 poj 1088
来源:互联网 发布:linux ed2k 终端 编辑:程序博客网 时间:2024/06/14 21:33
Description
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
一个人可以从某个点滑向上下左右相邻四个点之一,当且仅当高度减小。在上面的例子中,一条可滑行的滑坡为24-17-16-1。当然25-24-23-...-3-2-1更长。事实上,这是最长的一条。
Input
Output
Sample Input
5 5
1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9
Sample Output
25
题意: 从某一个点开始可以做最多的步数, 上一步的数值要大于下一步的数值,方向是当前四周的四个点
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 105
int dir[4][2] = {{0,1} , {0,-1} , {1,0} , {-1,0}};
int n, m; //n: row, m: column;
int a[MAX][MAX];
int dp[MAX][MAX];
inline int max(int a,int b)
{
}
int dfs(int i,int j)
{
}
int main()
{
//