yu55555 @ 2019-08-28 17:22:20
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<"["<<x<<"]" <<endl;
#define mem(a,b) memset(a,b,sizeof(a));
#define f(x,y) for(int x=1;x<=y;x++)
using namespace std;
const int mx=110;
int mp[mx][mx],dp[mx][mx];
int r,c,res;
int f[4][2]={0,1,0,-1,1,0,-1,0};
bool check(int x,int y){
if(x>=1&&x<=r&&y>=1&&y<=c)return true;
else return false;
}
bool bj(int x,int y){
int flag=0;
for(int i=0;i<4;i++){
int xx=x+f[i][0];
int yy=y+f[i][1];
if(!check(xx,yy)||mp[xx][yy]>mp[x][y])continue;
else flag=1;
}
if(flag==0)return true;
else return false;
}
int dfs(int x,int y){
if(dp[x][y]!=-1)return dp[x][y];
//if(x)return 1;
if(bj(x,y))return 1;
for(int i=0;i<4;i++){
int xx=x+f[i][0];
int yy=y+f[i][1];
if(!check(xx,yy)||mp[xx][yy]>mp[x][y])continue;
else dp[x][y]=max(dp[x][y],dfs(xx,yy)+1);
}
return dp[x][y];
}
int main(){
cin>>r>>c;
f(i,r)f(j,c)cin>>mp[i][j];
mem(dp,-1);
f(i,r)f(j,c)res=max(res,dfs(i,j));
cout<<res;
// cout<<dfs(2,3);
return 0;
}
by yu55555 @ 2019-08-28 17:22:40
才50分
by 只以 @ 2019-08-28 17:23:35
测试信息?
by yu55555 @ 2019-08-28 17:29:32
@只以 5个点MLE
by yu55555 @ 2019-08-28 17:32:15
@只以 https://www.luogu.org/record/23425690#
by yu55555 @ 2019-08-28 17:36:10
解决了!!
if(!check(xx,yy)||mp[xx][yy]>mp[x][y])continue;
应该大于等于
by yu55555 @ 2019-08-28 17:36:53
A了
by xiezhen @ 2019-08-28 17:44:04
tql
by 吾皇 @ 2019-08-28 17:46:00
tql
by 曦行夜落 @ 2019-08-29 08:26:35
为什么显示我被at了啊