zoukankan      html  css  js  c++  java
  • P1434-滑雪

     1 #include <bits/stdc++.h>
     2 using namespace std;
     3 #define _for(i,a,b) for(int i = (a);i < b;i ++)
     4 const int maxn = 110;
     5 
     6 int m[maxn][maxn];
     7 int ms[maxn][maxn];
     8 int R,C;
     9 int rnt = 1;
    10 int dx[] = {1,-1,0,0};
    11 int dy[] = {0,0,1,-1};
    12 bool valid(int x,int y)
    13 {
    14     return x>=0 && y>=0 && x<R && y<C;
    15 }
    16 int msf(int cx,int cy)
    17 {
    18     if(ms[cx][cy]) return ms[cx][cy];
    19     ms[cx][cy] = 1;
    20     _for(i,0,4)
    21     {
    22         int nx = cx+dx[i];
    23         int ny = cy+dy[i];
    24         
    25         if(valid(nx,ny) && m[nx][ny] < m[cx][cy])
    26             ms[cx][cy] = max(ms[cx][cy],msf(nx,ny)+1);
    27     }
    28     return ms[cx][cy];
    29 }
    30 int main()
    31 {
    32     scanf("%d%d",&R,&C);
    33     memset(m,0,sizeof(m));
    34     memset(ms,0,sizeof(ms));
    35     
    36     _for(i,0,R)
    37         _for(j,0,C)
    38             scanf("%d",&m[i][j]);
    39     
    40     _for(i,0,R)
    41         _for(j,0,C)
    42             rnt = max(rnt,msf(i,j));
    43     
    44     printf("%d
    ",rnt);
    45     return 0;
    46 }
  • 相关阅读:
    springboot-pom文件报错问题
    php-session永不过期
    linux mysql 配置
    jmeter
    性能指标
    ab
    php--xdebug调试
    logstash6-mysql同步数据到es
    php--宝塔环境
    linux-centos7安装错误解决
  • 原文地址:https://www.cnblogs.com/Asurudo/p/11248303.html
Copyright © 2011-2022 走看看