qpdk777 @ 2020-04-05 21:24:03
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
struct p{
int x,y,h;
bool operator <(const p b) const{
return this->h < b.h;
}
}t;
int r,c,n,a,b,ans;
int f[101][101];
priority_queue <p,vector<p>,less<p> >q;
int maxn(int a,int b,int c,int d){
return max(max(a,b),max(c,d));
}
int main(){
ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
cin>>r>>c;
for(int i = 1; i <= r; ++i)
for(int j = 1; j <= c; ++j){
cin>>t.h;
t.x = i,t.y = j;
q.push(t);
}
for(int i = 1; i <= c*r; ++i){
t = q.top();
q.pop();
a = t.x, b = t.y;
f[a][b] = maxn(f[a-1][b],f[a][b-1],f[a+1][b],f[a][b+1])+1;
}
for(int i = 1; i <= r; ++i)
for(int j = 1; j <= c; ++j)
ans = max(ans,f[i][j]);
cout<<ans<<endl;
return 0;
}
by HohleFeuerwerke @ 2020-04-05 21:25:03
btl, jbl
by Thomas_Cat @ 2020-04-05 21:25:19
btd
by IntrepidStrayer @ 2020-04-05 21:25:25
完美?
by Surelysuper @ 2020-04-05 21:25:35
完美?
by qpdk777 @ 2020-04-05 21:25:47
调了好久也不知道怎么办, 数据也没法下载
by Surelysuper @ 2020-04-05 21:25:50
@Thomas_Cat 正解
by tangrunxi @ 2020-04-05 21:25:57
码风差评,与标题不符,走了
by hanyuchen2019 @ 2020-04-05 21:30:36
++
by qpdk777 @ 2020-04-05 21:32:39
代码完美是假,WA了一半是真!
求救各位dalao
by aaddggddaa @ 2020-04-09 17:56:27
f的推进顺序并不是从上到下从左到右的,你这个不是搜索,只是从左上到右下推了一遍,但是结果有可能是从右下往上,或者是其他路径的。算法逻辑不够完善。这题广搜T了,记忆化深搜差不多