滑雪

//
// Created by ljs on 2018/8/28.
//poj 1088
//
#include 
using namespace std;
int m = 101, n = 101;
int dir[4][4] = {{-1, 0}, {0, 1},{1, 0}, {0, -1}};
int maze[101][101];
int maxlength = -1;
void dfs(int x, int y, int cur){
    if(cur > maxlength){
        maxlength = cur;
    }
    for(int i = 0; i < 4; i++){
        int xx = x + dir[i][0];
        int yy = y + dir[i][1];
        if(xx < 0 || xx >= m || yy < 0 || yy >= n || maze[xx][yy] >= maze[x][y]){
            continue;
        }
        dfs(xx, yy, cur+1);
    }
}
int main(){
    cin>>m>>n;
    for(int i = 0; i < m ;i++){
        for(int j = 0; j < n; j++){
            cin>>maze[i][j];
        }
    }
    for(int i = 0; i < m;i++){
        for(int j = 0; j < n;j++){
            dfs(i,j,1);
        }
    }
    cout<

你可能感兴趣的:(滑雪)