【POJ】1088滑雪
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 97335 | Accepted: 36911 |
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
Source
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
inline int read(){
int x=0,f=1;char c=getchar();
for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=getchar()) x=x*10+c-'0';
return x*f;
} int Map[101][101];
int rez[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int a[101][101];
int N,M; int ans=-99999; int SER(int x,int y){
if(a[x][y]) return a[x][y];
int k=1;
for(int i=0;i<4;i++){
int xx=x+rez[i][0];
int yy=y+rez[i][1];
if(Map[xx][yy]>=Map[x][y]) continue;
if(xx<1||xx>N||yy<1||yy>M) continue;
k=max(k,SER(xx,yy)+1);
}
a[x][y]=k;
return k;
} int main(){
N=read(),M=read();
for(int i=1;i<=N;i++){
for(int j=1;j<=M;j++)
Map[i][j]=read();
}
for(int i=1;i<=N;i++)
for(int j=1;j<=M;j++)
ans=max(ans,SER(i,j));
printf("%d\n",ans);
}
【POJ】1088滑雪的更多相关文章
- POJ 1088 滑雪(记忆化搜索+dp)
POJ 1088 滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 107319 Accepted: 40893 De ...
- POJ 1088 滑雪(记忆化搜索)
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 92384 Accepted: 34948 Description ...
- POJ 1088 滑雪 【记忆化搜索经典】
题目链接:http://poj.org/problem?id=1088 滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: ...
- POJ 1088 滑雪 -- 动态规划
题目地址:http://poj.org/problem?id=1088 Description Michael喜欢滑雪百这并不奇怪, 因为滑雪的确很刺激.可是为了获得速度,滑的区域必须向下倾斜,而且当 ...
- OpenJudge/Poj 1088 滑雪
1.链接地址: bailian.openjudge.cn/practice/1088 http://poj.org/problem?id=1088 2.题目: 总Time Limit: 1000ms ...
- poj 1088 滑雪(区间dp+记忆化搜索)
题目链接:http://poj.org/problem?id=1088 思路分析: 1>状态定义:状态dp[i][j]表示在位置map[i][j]可以滑雪的最长区域长度: 2>状态转移方程 ...
- POJ 1088 滑雪 (记忆化搜索)
题目链接:http://poj.org/problem?id=1088 题意很好懂,就是让你求一个最长下降路线的长度. dp[i][j]记录的是i j这个位置的最优的长度,然后转移方程是dp[i][j ...
- poj 1088 滑雪 DP(dfs的记忆化搜索)
题目地址:http://poj.org/problem?id=1088 题目大意:给你一个m*n的矩阵 如果其中一个点高于另一个点 那么就可以从高点向下滑 直到没有可以下滑的时候 就得到一条下滑路径 ...
- POJ 1088 滑雪 DFS 记忆化搜索
http://poj.org/problem?id=1088 校运会放假继续来水一发^ ^ 不过又要各种复习,功课拉下了许多 QAQ. 还有呀,就是昨天被一个学姐教育了一番,太感谢了,嘻嘻^ ^ 好了 ...
- POJ 1088滑雪
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 89168 Accepted: 33474 Description ...
随机推荐
- Python作业模拟登陆(第一周)
模拟登陆:1. 用户输入帐号密码进行登陆2. 用户信息保存在文件内3. 用户密码输入错误三次后锁定用户 思路: 1. 用户名密码文件为passwd,锁定用户文件为lock 2. 用户输入账号密码采用i ...
- sqlmap参数说明
--delay 设置每隔几秒测试一次注入 --safe-url 设置sqlmap要访问的正常url --safe-freq 设置每测试多少条注入语句后才去访问safe-url --code 设置能正常 ...
- device tree --- #interrupt-cells property
device tree source Example1 interrupt-controller@e000e100 { ... ... #interrupt-cells = <0x1>; ...
- python基础===将json转换为dict的办法
首先json是字符串. 大家都知道,字符串是用来传递信息的.json字符串实际上就是一种规定了格式的字符串, 通过这种格式,我们可以在不同的编程语言之间互相传递信息,比如我们可以把javascript ...
- python基础===两个list之间移动元素
首先我们先了解一下list的几个常用函数: a = [123,456,"tony","jack"] #list中增加元素a.append("www&q ...
- 12-5 NSSet
原文:http://rypress.com/tutorials/objective-c/data-types/nsset NSSet NSSet, NSArray, and NSDictionary ...
- 创建.dat文件(转载)
比较有用的东比较有用的东西 首先,批处理文件是一个文本文件,这个文件的每一行都是一条DOS命令(大部分时候就好象我们在DOS提示符下执行的命令行一样),你可以使用DOS下的Edit或者Windows的 ...
- POJ-2778
DNA Sequence Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12726 Accepted: 4862 Des ...
- LeetCode解题报告—— Word Search & Subsets II & Decode Ways
1. Word Search Given a 2D board and a word, find if the word exists in the grid. The word can be con ...
- HTTP协议——请求与响应
摘要:1.HTTPHTTP:HyperTextTransferProtocol,超文本传输协议的缩写,是本地浏览器和服务器之间进行通信的传送协议.基于TCP/IP协议来传送数据,如HTML文件,图片等 ...