aqzjklo @ 2024-05-11 17:48:08
#include <bits/stdc++.h>
using namespace std;
int r,c,a[105][105],f[105][105],ans;//f[i][j]代表第i行第j列的最长题意长度
int main()
{
cin >>r >> c;
for (int i=1; i <=r; i++)
{
for (int j = 1; j <= c; j++)
{
cin >> a[i][j];
}
}
for (int i = 1; i <= r; i++)
{
for (int j = 1; j <= c; j++)
{
f[i][j]=1;//初始每个点都可以滑雪,赋值1
}
}
for (int i = 1; i <= r; i++)
{
for (int j = 1; j <= c; j++)
{
if (i+1<=r&&a[i][j]>a[i+1][j])
{
f[i][j]=max(f[i][j],f[i+1][j]);
}
if (i-1>0&&a[i][j]>a[i-1][j])
{
f[i][j]=max(f[i][j],f[i-1][j]);
}
if (j+1<=c&&a[i][j]>a[i][j+1])
{
f[i][j]=max(f[i][j],f[i][j+1]);
}
if (j-1>0&&a[i][j]>a[i][j-1])
{
f[i][j]=max(f[i][j],f[i][j-1]);
}
++f[i][j];
ans=max(ans,f[i][j]);
}
}
cout << ans;
}
十分感谢!
by lwhxxx @ 2024-05-11 18:36:12
666
by aqzjklo @ 2024-06-26 08:25:57
@lwhxxx ?