BNUOJ 1207 滑雪
滑雪
64-bit integer IO format: %lld Java class name: Main
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 <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <climits>
#include <ctype.h>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
int rows,cols;
int table[][],rec[][];
int solve(int x,int y,int height){
if(x < || y < || x >= rows || y >= cols || table[x][y] <= height)
return ;
if(rec[x][y]) return rec[x][y];
rec[x][y] = max(rec[x][y],solve(x-,y,table[x][y]));
rec[x][y] = max(rec[x][y],solve(x+,y,table[x][y]));
rec[x][y] = max(rec[x][y],solve(x,y+,table[x][y]));
rec[x][y] = max(rec[x][y],solve(x,y-,table[x][y]));
return ++rec[x][y];
}
int main(){
int i,j,mx,temp;
scanf("%d %d",&rows,&cols);
for(i = ; i < rows; i++){
for(j = ; j < cols; j++){
scanf("%d",table[i]+j);
rec[i][j] = ;
}
}
for(mx = i = ; i < rows; i++){
for(j = ; j < cols; j++){
temp = solve(i,j,INT_MIN);
if(temp > mx) mx = temp;
}
}
printf("%d\n",mx);
return ;
}
BNUOJ 1207 滑雪的更多相关文章
- BNUOJ 23905 滑雪
滑雪 Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on UESTC. Original ID: 13096 ...
- tyvj1004 滑雪
描述 trs喜欢滑雪.他来到了一个滑雪场,这个滑雪场是一个矩形,为了简便,我们用r行c列的矩阵来表示每块地形.为了得到更快的速度,滑行的路线必须向下倾斜. 例如样例中的那个矩形,可以从某 ...
- bzoj 2753: [SCOI2012] 滑雪与时间胶囊 Label:MST
题目描述 a180285非常喜欢滑雪.他来到一座雪山,这里分布着M条供滑行的轨道和N个轨道之间的交点(同时也是景点),而且每个景点都有一编号i(1<=i<=N)和一高度Hi.a180285 ...
- USACO 2014 JAN 滑雪录像
2. 滑雪录像{silver题3} [问题描述] 冬奥会的电视时刻表包含N (1 <= N <= 150)个节目,每个节目都有开始和结束时间.农民约翰有两台录像机,请计算他最多可以录制多少 ...
- USACO 滑雪课程
#include<cstdio> #include<iostream> using namespace std; int T,S,N,maxd; ],lv[],next[],f ...
- BNUOJ 52325 Increasing or Decreasing 数位dp
传送门:BNUOJ 52325 Increasing or Decreasing题意:求[l,r]非递增和非递减序列的个数思路:数位dp,dp[pos][pre][status] pos:处理到第几位 ...
- Bzoj2753 [SCOI2012]滑雪与时间胶囊
2753: [SCOI2012]滑雪与时间胶囊 Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 2282 Solved: 796 Descriptio ...
- 滑雪 why WA
滑雪 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 587 Solved: 219 Description 小明喜欢滑雪,因为滑雪的确很刺激,可是为了获 ...
- bnuoj 24251 Counting Pair
一道简单的规律题,画出二维表将数字分别相加可以发现很明显的对称性 题目链接:http://www.bnuoj.com/v3/problem_show.php?pid=24251 #include< ...
随机推荐
- moment.js获取当前日期是当年的第几周
/** * 实现当前日期是当年的第几周,再向前和向后推几周 * js数组保存当前日期的前后两周(共五周的数据) * */ var initSearchMajorChanges = function() ...
- 测试ReplicaSets读写分离和故障转移
读写分离实现步骤: 从库能够进行查询就更好了,这样可以分担主库的大量的查询请求. 1) 先向主库中插入一条测试数据 rs1:PRIMARY> db.c1.insert({age:30});db. ...
- mongodb主从配置信息查看与确认
在local库中不仅有主从日志 oplog集合,还有一个集合用于记录主从配置信息 system.replset: > use local > show collections > d ...
- 通过StringBuilder的reverse()实现倒序
import java.util.Scanner; public class ReverseString { public static void main(String[] args) { Scan ...
- Grid Infrastructure 启动的五大问题 (文档 ID 1526147.1)
适用于: Oracle Database - Enterprise Edition - 版本 11.2.0.1 和更高版本本文档所含信息适用于所有平台 用途 本文档的目的是总结可能阻止 Grid In ...
- select *from where 和select *from jion on 语句的差别
https://zhidao.baidu.com/question/541791438.html select 学号 a,成绩 a,姓名 b from 成绩表 a,学生表 b where a.学号=b ...
- 用”人话”解释CNN —— 对单个特征图进行视觉化
转载自:http://nooverfit.com/wp/pycon-2016-tensorflow-研讨会总结-tensorflow-手把手入门-用人话解释cnn 首先什么是CNN? 其实, 用”人话 ...
- react native在xcode真机调试ios
1修改URL地址:打开项目目录下的AppDelegate.m文件,修改里面的URL,把localhost改为你的电脑的IP.在Mac系统下,你可以在系统设置/网络里找到电脑的IP地址. 2选择设备:把 ...
- Evaluate|GC content|Phred|BAC|heterozygous single nucleotide polymorphisms|estimate genome size|
(Evaluate):检查reads,可使用比对软件:使用SOAPaligner重新排列:采用massively parallel next-generation sequencing technol ...
- c++中的结构体:声明 定义 初始化
什么是结构体? 之前的学习中我们知道了数组是一个容器,而且是存放固定大小数据的容器,而且存放的元素的数据类型必须要一致. 比如数据库中有这样的一条记录学号 性别 年龄 成绩 地址应该怎样存放 结构体: ...