提交时间:2024-03-30 14:27:04
运行 ID: 140320
# include <bits/stdc++.h> using namespace std ; int a [104] [104] , m , n , mx ; void dfs ( int x , int y , int l ) { if ( x == 0 || y == 0 ) { return ; } if ( a [x + 1] [y] < a [x] [y] ) { dfs ( x + 1 , y , l + 1 ) ; } if ( a [x - 1] [y] < a [x] [y] ) { dfs ( x - 1 , y , l + 1 ) ; } if ( a [x] [y + 1] < a [x] [y] ) { dfs ( x , y + 1 , l + 1 ) ; } if ( a [x] [y - 1] < a [x] [y] ) { dfs ( x , y - 1 , l + 1 ) ; } mx = max ( mx , l ) ; } int main ( ) { cin >> m >> n ; for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { cin >> a [i] [j] ; } } for ( int i = 1 ; i <= m ; i ++ ) { for ( int j = 1 ; j <= n ; j ++ ) { dfs ( i , j , 1 ) ; } } cout << mx << endl ; return 0 ; }