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. 01-虚拟软件vmware安装

    什么是虚拟软件: 虚拟原件是一个可以使你在一台机器上同时运行二个或更多Windows.LINUX等系统.它可以模拟一个标准PC环境.这个环境和真实的计算机一样,都有芯片组.CPU.内存.显卡.声卡.网 ...

  2. Docker background

    什么是 Docker? Docker 提供了一个可以运行你的应用程序的封套(envelope),或者说容器.它原本是 dotCloud 启动的一个业余项目,并在前些时候开源了.它吸引了大量的关注和讨论 ...

  3. ios开发之--把秒转换为天时分秒

    把秒转换成时分秒: - (NSString *)timeFormatted:(int)totalSeconds { ; ) % ; ; return [NSString stringWithForma ...

  4. Windows最全快捷键

    单独按Windows:显示或隐藏“开始”功能表 Windows+BREAK:显示“系统属性” 对话框 Windows+D:显示桌面 Windows+M:最小化所有窗口 Windows+Shift+M: ...

  5. Maven发布war包到Tomcat

    一.修改Tomcat下配置文件tomcat-users.xml,然后启动 <role rolename="manager-gui"/> <role rolenam ...

  6. AESDK开发之UI消息响应

    UI创建: 在该入口下 case PF_Cmd_PARAMS_SETUP: //.... break; 必须在末尾指定UI数目,UI数目一般是枚举,如果和枚举长度不一致也会报错.所以最好是直接修改枚举 ...

  7. 音频——H5 audio

    分享站又有新功能了:将文件站上的语音文件正确播放出来.效果图: 暂停: 播放: 实现的效果:类似于音乐播放器一般,但是较之更简单一些,可以正常播放语音,有拖动.快进后退效果便可. 思路: 首先想到的便 ...

  8. Android Studio Error:Connection timed out: connect.解决方案

    遇到了这样的错误: Error:Connection timed out: connect. If you are behind an HTTP proxy, please configure the ...

  9. 脚本学习 game.sh

    #!/bin/bash #game_error.sh ]]; then #$#表示参数个数 -lt小于 echo "Usage: game_error.sh time[20170710]&q ...

  10. Android 手机震动

    1.添加震动权限 <uses-permission android:name="android.permission.VIBRATE"/> 2.获取震动服务 Vibra ...