- 清帝之惑之顺治
- 2019-07-29 16:33:54 @
a=[]
r,c=map(lambda x:int(x),input().split())
a.append([int(99999) for i in range(c+2)])
m=[[-1 for i in range(c+2)] for j in range(r+2)]
for i in range(1,r+1):
a.append(list(map(int, input().split())))
a[i].insert(0,int(99999))
a[i].append(int(99999))
a.append([int(99999) for i in range(c+2)])
dx=[-1,1,0,0]
dy=[0,0,-1,1]
def count(x,y):
if a[x][y]<a[x-1][y] and a[x][y]<a[x+1][y] and a[x][y]<a[x][y-1] and a[x][y]<a[x][y+1]:
if m[x][y]==-1:
m[x][y]=1
return 1
maxe=0
for i in range(4):
if a[x][y]>a[x+dx[i]][y+dy[i]]:
if m[x+dx[i]][y+dy[i]]==-1:
maxe=max(maxe,count(x+dx[i],y+dy[i])+1)
else:
maxe=max(maxe,m[x+dx[i]][y+dy[i]]+1)
m[x][y]=maxe
return maxe
klkl=0
for i in range(1,r+1):
for j in range(1,c+1):
if m[i][j]==-1:
klkl=max(klkl,count(i,j))
else:
klkl=max(klkl,m[i][j])
print(klkl)