http://bailian.openjudge.cn/practice/1088?lang=en_US

题解:

 设一个dp[N][N]数组代表从(i,j)坐标开始能滑到的最远距离。
更新的方法为 遍历每个dp[i][j], 对其四周(下一个状态)的点更新。
更新顺序为从低到高。所以用priority_queue存数据。 坑:
  一开始更新的时候没有写dp=max(dp,····)
  也忘记了答案是dp数组的最大值
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<cstring>
#include<set>
#include<algorithm>
#include<stack>
#include<string>
#include<cstdio>
#include<list>
#include<cstdlib>
#include<queue> #define _for(i, a, b) for (int i = (a); i<(b); ++i)
using namespace std;
const int N = + ;
const int INF = 1e6;
int map[N][N];
int dp[N][N];//从i,j开始能滑到的最远距离。dp[i][j] 对其四周的点更新。更新顺序为从高到底。
struct node {
int x, y, w;
node(int x = , int y = , int w = ) :x(x), y(y), w(w) {}
bool operator< (const node &b)const {
return w > b.w;
}
};
int dir[][] = { ,, ,-, -,, , };
priority_queue<node> Q;
int main() {
int c, r;
cin >> r >> c;
_for(i, , r)
_for(j, , c) {
cin >> map[i][j];
Q.push(node(i, j, map[i][j]));
dp[i][j] = ;
}
int ans = ; while (!Q.empty()) {
node now = Q.top(); ans = max(ans, dp[now.x][now.y]); Q.pop();
for (int i = ; i < ; i++) {
int dx = now.x + dir[i][];
int dy = now.y + dir[i][];
if (dx< || dx >= r || dy< || dy >= c)continue;
if (map[dx][dy] > now.w) dp[dx][dy] = max(dp[dx][dy], dp[now.x][now.y] + ); }
}
cout << ans;
//while (!Q.empty()) {cout << Q.top().w;Q.pop();}
system("pause");
}

POJ - 1088 滑雪 dp的更多相关文章

  1. poj 1088 滑雪 DP(dfs的记忆化搜索)

    题目地址:http://poj.org/problem?id=1088 题目大意:给你一个m*n的矩阵 如果其中一个点高于另一个点 那么就可以从高点向下滑 直到没有可以下滑的时候 就得到一条下滑路径 ...

  2. POJ 1088 滑雪(记忆化搜索+dp)

    POJ 1088 滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 107319   Accepted: 40893 De ...

  3. POJ 1088 滑雪(记忆化搜索)

    滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 92384   Accepted: 34948 Description ...

  4. POJ 1088 滑雪 【记忆化搜索经典】

    题目链接:http://poj.org/problem?id=1088 滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:  ...

  5. poj 1088 滑雪(区间dp+记忆化搜索)

    题目链接:http://poj.org/problem?id=1088 思路分析: 1>状态定义:状态dp[i][j]表示在位置map[i][j]可以滑雪的最长区域长度: 2>状态转移方程 ...

  6. POJ 1088 滑雪 记忆化DP

    滑雪 Time Limit: 1000MS   Memory Limit: 65536K       Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度 ...

  7. POJ 1088: 滑雪(经典 DP+记忆化搜索)

    滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 74996   Accepted: 27818 Description ...

  8. POJ 1088 滑雪(简单的记忆化dp)

    题目 又一道可以称之为dp的题目,虽然看了别人的代码,但是我的代码写的还是很挫,,,,,, //看了题解做的简单的记忆化dp #include<stdio.h> #include<a ...

  9. POJ 1088 滑雪 -- 动态规划

    题目地址:http://poj.org/problem?id=1088 Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当 ...

随机推荐

  1. MapWinGIS------引发类型为“System.Windows.Forms.AxHost+InvalidActiveXStateException”的异常

    转载:http://www.cnblogs.com/dzone/archive/2011/09/08/2171445.html

  2. How to solve the problem : &quot;You have been logged on with a temporary profile&quot;

    /*By Jiangong SUN*/ I've encountered a problem in one server, which is : Every time I login into the ...

  3. UDP通信-UdpClient

    static void Main(string[] args) { Console.WriteLine("发送端"); byte[] buffer = System.Text.En ...

  4. python关键字与标识符

    编程语言众多,但每种语言都有相应的关键字,Python 也不例外,它自带了一个 keyword 模块,用于检测关键字. 关键字列表 进入 Python 交互模式,获取关键字列表: >>&g ...

  5. 转载 IMP时数据库的IO性能监控,并提供IOPS的计算方法

     IMP时数据库的IO性能监控,并提供IOPS的计算方法 2011-07-15 17:36:10 分类: Linux [root@ntkdb oradata]# iostat -x 1 10     ...

  6. 【安全开发】Perl安全编码规范

    多年以来,Perl已经成为用于系统管理和WebCGI开发的功能最强的编程语言之一(几乎可以使用Perl做任何功能的程序).但其扩展应用,即作为Internet上CGI的开发工具,使得它经常成为Web服 ...

  7. Studio更新

    其实最主要的是下面三个步骤: 1.更新As工程为3.0 2.必须升级gradle到4.0以上 3.buildToolsVersion升级到26.0.0 4.在gradle.properties中配置版 ...

  8. oracle数据据 Python+Pandas 获取Oracle数据库并加入DataFrame

    import pandas as pd import sys import imp imp.reload(sys) from sqlalchemy import create_engine impor ...

  9. linux文件和目錄管理的基本命令命令

    ls命令 作用:顯示目標列表或目錄的內容 語法:ls[選項][目錄或文件] -a:顯示指定目錄下所有子目錄與文件,包括隱藏文件 -l:顯示文件的詳細信息 -d: 顯示目錄 例:ls -dl cd命令 ...

  10. iOS - 截屏,view截图的基本方法

    推荐一个第三方好用的框架:SDScreenshotCapture #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice cur ...