那一条变阻器 @ 2019-07-20 11:14:46
还有哪里可以优化呀?
#include <bits/stdc++.h>
using namespace std;
int r , c , ans = 1 , xx , yy , k;
int dx[4] = {1 , 0 , -1 , 0} , dy[4] = {0 , 1 , 0 , -1};
int a[105][105] , f[105][105];
void search(int x , int y , int step){
if(ans < step) ans = step;
if(ans == r * c){
cout << ans;
exit(0);
}
for(int v = 0; v < 4; v++){
int nx = x + dx[v] , ny = y + dy[v];
if(nx >= 1 && nx <= r && ny >= 1 && ny <= c && a[x][y] > a[nx][ny]){
search(nx , ny , step + 1);
}
}
}
int main(){
cin >> r >> c;
for(int i = 1; i <= r; i++){
for(int j = 1; j <= c; j++){
scanf("%d" , &a[i][j]);
}
}
for(int i = 1; i <= r; i++)
for(int j = 1; j <= c; j++)
search(i , j , 1);
cout << ans;
return 0;
}
by LordLeft @ 2019-07-20 11:15:59
E?
Zhe Bu Shi DP Ti Mu Ma?
by 雪树蟋蟀 @ 2019-07-20 11:17:18
@LordLeft 大哥您能好好说话吗
by LordLeft @ 2019-07-20 11:17:58
@雪树蟋蟀
Wo De Zhong Wen Shu Ru Fa Huan Le...
by 雪树蟋蟀 @ 2019-07-20 11:21:09
@LordLeft 。。。。。。
by foxdemon @ 2019-07-20 11:21:22
@LordLeft Orz , nin tai qiang le
by 梧桐灯 @ 2019-07-20 11:26:08
@LordLeft 很明显应该是huai leQAQ
by 梧桐灯 @ 2019-07-20 11:26:38
@皇帝de优秀 记忆化搜索了解一下
by 那一条变阻器 @ 2019-07-20 11:29:42
@光随影走不太会记忆化呀