(DP6.1.4.2)POJ 1088 滑雪
来源:互联网 发布:淘宝运营每日工作内容 编辑:程序博客网 时间:2024/06/06 17:00
其实下面用到的是搜索。(呜呜,DP写的过了测试用例但是却总是AC不了,所以改用搜索来做了)
/* * POJ_1088.cpp * * Created on: 2013年10月13日 * Author: Administrator */#include <iostream>#include <cstdio>using namespace std;const int maxn = 110;int a[maxn][maxn];int d[maxn][maxn];int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1} };int r,c;void run(int x,int y){if(d[x][y] > 0){return ;}d[x][y] = 1;int i,j; for(i = 0 ; i < 4 ; ++i){ int xx = x + dir[i][0]; int yy = y + dir[i][1]; if(xx >= 0 && xx <r && yy >= 0 && yy < c && a[xx][yy] < a[x][y]){ run(xx,yy); if(d[xx][yy] + 1 > d[x][y]){ d[x][y] = d[xx][yy] + 1; } } }}int main(){while(scanf("%d%d",&r,&c)!=EOF){int i,j;for(i = 0 ; i < r ; ++i){for(j = 0 ; j < c ; ++j){scanf("%d",&a[i][j]);}}int maxStep = 0;for(i = 0 ; i < r; ++i){for(j = 0 ; j < c ; ++j){if(d[i][j] == 0){run(i,j);if(d[i][j] > maxStep){maxStep = d[i][j];}}}}printf("%d\n",maxStep);}return 0;}
- (DP6.1.4.2)POJ 1088 滑雪
- POJ 1088 滑雪
- POJ 1088 滑雪
- POJ 1088 滑雪
- Poj 1088 滑雪
- poj 1088 滑雪
- 滑雪--POJ--1088
- poj 1088 滑雪(DP)
- POJ 1088 滑雪
- POJ 1088 滑雪
- poj 1088 滑雪
- POJ 1088 滑雪
- poj 1088 滑雪
- POJ 1088 滑雪
- poj 1088 滑雪
- poj 1088 滑雪
- POJ 1088 滑雪 DP
- POJ 1088 滑雪
- Linux环境下Navicat 11无限制使用的办法
- Xcode学习笔记---如何学好Objective C
- 简单的正则表达式匹配 Regular Expression Matching
- iPad必备学习应用推荐
- Java程序员必知道的八大排序算法(一 )
- (DP6.1.4.2)POJ 1088 滑雪
- Ext4 创建类 Ext.define
- EBS 财务辅助工具开发手记--类设计
- Please ensure that adb is correctly located at……问题解决方案
- jaxb 通过xml转ava对象
- WF4.0 基础篇 (二十七) WCF Workflow Service 在WCF中使用WF
- zedboard--ubuntu12.04(pc机下)下helloworld驱动从失败到成功过程
- #pragma warning (disable: 4786)
- 小水硕面试经验谈