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< ...
随机推荐
- IDEA JavaSE环境配置
需指定JDK路径: File -> Project Structure -> Project -> Project SDK -> New -> 选择JDK所在的根目录
- CF1072B Curiosity Has No Limits
思路: 对于序列t,只要第一个数确定了,后续的数也随之确定了.枚举四种情况即可.实现: #include <iostream> #include <vector> using ...
- cf1028C. Rectangles(前缀和)
题意 给出$n$个矩形,找出一个点,使得至少在$n$个矩阵内 Sol 呵呵哒,昨天cf半夜场,一道全场切的题,我没做出来..不想找什么理由,不会做就是不会做.. 一个很显然的性质,如果存在一个点 / ...
- git处理时的问题
1. 在node.js开发的时候常常会遇到从别人的远程仓库中clone时出现文件名过长的错误, 或则是在本地npm下载之后的文件进行上传到自己的远程仓库的时候会出现 File too long的情况, ...
- shell流程语句使用介绍
1)使用if.case.read例子1:#!/bin/bash#读取终端输入的字符read -p "Please input a Number:" nn1=`echo $n|sed ...
- VirtualKD + Windbg 调试Win10虚拟机
安装完vminstall后,先在运行中输入"msconfig"命令,显示如下窗口. 首先点击“引导”选项卡,然后选择最后一个引导项(Disable Signature Enforc ...
- SAP CRM中间件下载equipment时遇到的一个错误
在CRM开发系统上进行equipment下载,发现不工作.调试发现错误信息在下图定96行的WHEN default分支抛出的: MESSAGE ID 'AZ' ... 通过阅读源代码发现,ERP端支持 ...
- 微信程序开发系列教程(四)使用微信API创建公众号自定义菜单
大家可能经常看到一些微信公众号具有功能强大的自定义菜单,点击之后可以访问很多有用的功能. 这篇教程就教大家如何动手做一做. 这个教程最后实现的效果是:创建一个一级菜单"UI5", ...
- 校内选拔I题题解 构造题 Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2) ——D
http://codeforces.com/contest/574/problem/D Bear and Blocks time limit per test 1 second memory limi ...
- fgetc, fgets, getc, getchar, gets, ungetc - 输入字符和字符串
总览 (SYNOPSIS) #include <stdio.h> int fgetc(FILE *stream); char *fgets(char *s, int size, FILE ...