求助啊啊啊 90分

P1434 [SHOI2002] 滑雪

Taunt @ 2016-10-11 21:35:40

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=110;
int n,m,maxx=0;
int map[maxn][maxn],dis[maxn][maxn];
int dx[10]={0,0,0,1,-1},dy[10]={0,1,-1,0,0};
int step,t,l;
int  dfs(int x,int y){
    if(dis[x][y])    return dis[x][y];
    step=0;
    for(int i=1;i<=4;i++){
        int x1=x+dx[i],y1=y+dy[i];
        if(x1>0&&y1>0&&x1<=n&&y1<=m&&map[x1][y1]<map[x][y]){
            t=dfs(x1,y1);
            if(t>step)    step=t;
        }
    }
    dis[x][y]=step+1;
    return dis[x][y];
}
int main(){
    //freopen("in.txt","r",stdin);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
        cin>>map[i][j];
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
        l=dfs(i,j);
        if(l>maxx)    maxx=l;
    }
    cout<<maxx;
    return 0;
}

by 46days @ 2016-10-11 21:44:35

666


by 46days @ 2016-10-11 21:45:54

我懒得看了,要不我把我过的代码发给你?


|