陈泓兆 @ 2018-08-16 10:52:31
#include <iostream>
using namespace std;
int n, m;
int a[105][105];
int cnt[105][105];
int xx[5] = {-1, 0, 1, 0};
int yy[5] = {0, -1, 0, 1};
void dfs(int x, int y)
{
int i, k = 0;
for (i = 0; i < 4; i++)
if (a[x + xx[i]][y + yy[i]] < a[x][y])
{
cnt[x + xx[i]][y + yy[i]] = max(cnt[x + xx[i]][y + yy[i]], cnt[x][y] + 1);
dfs(x + xx[i], y + yy[i]);
}
else k++;
if (k == 4) return;
}
int main()
{
int i, j, maxn = 0;
cin >> n >> m;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
{
cin >> a[i][j];
cnt[i][j] = 1;
}
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
dfs(i, j);
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
maxn = max(maxn, cnt[i][j]);
cout << maxn << endl;
system("pause");
return 0;
}
by PBCWZCC @ 2018-08-19 19:27:18
搞不好是
您用<
by PBCWZCC @ 2018-08-19 19:28:52
这个你应该在提交时去掉了吧
system("pause");