Inferior_dust @ 2023-07-24 17:00:56
#include <bits/stdc++.h>
using namespace std ;
int n , m ;
int a[10100][10100] ;
int main ( )
{
int MAXX = -0x7fffffff ;
int MINN = 0x7fffffff ;
cin >> n >> m ;
for ( int i = 1 ; i <= n ; i ++ ) {
for ( int j = 1 ; j <= m ; j ++ ) {
cin >> a[i][j] ;
MAXX = max ( MAXX , a[i][j] ) ;
MINN = min ( MINN , a[i][j] ) ;
}
}
cout << MAXX - MINN + 1 ;
return 0 ;
}
by yzm0325 @ 2023-07-24 17:05:32
so?
by ran_qwq @ 2023-07-24 17:09:27
so?
by w9095 @ 2023-07-24 17:14:33
so?
by __My0217__ @ 2023-07-24 17:17:47
so?
by Inferior_dust @ 2023-07-24 20:18:56
emmmm。。。。So 我用记忆化搜索做了一遍
by Inferior_dust @ 2023-07-24 20:27:47
但是我有两个点wa了
#include <bits/stdc++.h>
using namespace std ;
int key = 1 ;
int n , m ;
int MAXX = -1 ;
int a[101000][110] ;
int f[101000][110] ;
int lsp ( int x , int y ) {
if ( x > n || y > m || x < 1 || y < 1 ) return 0 ;
if ( f[x][y] ) return f[x][y] ;
f[x][y] = 1 ;
int o1 = 0 , o2 = 0 , o3 = 0 , o4 = 0 ;
if ( y - 1 > 0 && a[x][y] > a[x][y - 1] ){
lsp ( x , y - 1 ) ;
o1 = max ( f[x][y] , f[x][y - 1] + 1 ) ;
}
if ( y + 1 <= m && a[x][y] > a[x][y + 1] ){
lsp ( x , y + 1 ) ;
o2 = max ( f[x][y] , f[x][y + 1] + 1 ) ;
}
if ( x - 1 > 0 && a[x][y] > a[x - 1][y] ) {
lsp ( x - 1 , y ) ;
o3 = max ( f[x][y] , f[x - 1][y] + 1 ) ;
}
if ( x + 1 <= n && a[x][y] > a[x + 1][y] ) {
lsp ( x + 1 , y ) ;
o4 = max ( f[x][y] , f[x + 1][y] + 1 ) ;
}
int res = max ( max ( o1 , o2 ) , max ( o3 , o4 ) ) ;
f[x][y] = res ;
return f[x][y] ;
}
int main ( )
{
ios::sync_with_stdio(0) ;
memset ( a , 0 , sizeof ( a ) ) ;
cin >> n >> m ;
for ( int i = 1 ; i <= n ; i ++ ) {
for ( int j = 1 ; j <= m ; j ++ ) {
cin >> a[i][j] ;
}
}
for ( int i = 1 ; i <= n ; i ++ ) {
for ( int j = 1 ; j <= m ; j ++ ) {
key = max ( key , lsp ( i , j ) ) ;
}
}
printf ( "%d\n" , key + 1 ) ;
return 0 ;
}
/*
5 5
1 4 3 4 7
2 3 4 5 7
3 4 6 5 4
5 6 8 4 3
1 7 7 8 4
*/