清衡 @ 2018-05-29 10:34:44
RT
using namespace std; int r,c,st=1; int f[101][101],h[101][101]; int dx[5]={0,1,-1,0,0},dy[5]={0,0,0,1,-1}; bool vis[101][101]; int dfs(int x,int y) { int t; for(int i=1;i<=4;i++) { if(h[x][y]>h[x+dx[i]][y+dy[i]]&&x+dx[i]>=0&&x+dx[i]<=r&&y+dy[i]>=0&&y+dy[i]<=c) { f[x][y]=max(f[x][y],dfs(x+dx[i],y+dy[i])+1); } } return f[x][y]; } int main() { scanf("%d%d",&r,&c); for(int i=1;i<=r;i++) for(int j=1;j<=c;j++) { scanf("%d",&h[i][j]); f[i][j]=1; } int maxx=0; for(int i=1;i<=r;i++) for(int j=1;j<=c;j++) { dfs(i,j); if(maxx<f[i][j])maxx=f[i][j]; } printf("%d",maxx); return 0; }
by つきみやあゆ @ 2018-05-29 10:49:25
@灬Eternal丶 第二个点是一条链
by 清衡 @ 2018-05-31 14:32:52
@つきみやあゆ 那我应该怎么办呢? QAQ
by 准点的星辰 @ 2018-06-03 18:36:10
我也想知道怎么办??
by 准点的星辰 @ 2018-06-03 18:44:17
@灬Eternal丶 或许您应该开个o2,dfs+记忆化+o2才过。
by 清衡 @ 2018-06-04 16:28:38
@准点的星辰 我现在想特判...
by 准点的星辰 @ 2018-06-04 16:58:05
…………@灬Eternal丶
by 清衡 @ 2018-06-04 17:04:19
@准点的星辰 我能怎么办?我也很绝望啊。
by 准点的星辰 @ 2018-06-04 18:54:10
@灬Eternal丶
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
const int N=105;
int r,c;
int maxn;
int sh,sl,maxx=-999999;
int a[N][N],book[N][N];
int mh[5]={0,1,-1,0,0};
int ml[5]={0,0,0,1,-1};
queue<int>qh,ql;
inline void dfs(int h,int l,int ans)
{
if (ans<=book[h][l])
return ;
book[h][l]=ans;
for (int i=1;i<=4;i++)
{
int nh=h+mh[i];
int nl=l+ml[i];
if (nh>=1&&nh<=r&&nl>=1&&nl<=c&&a[h][l]>a[nh][nl])
{
dfs(nh,nl,ans+1);
}
}
maxn=max(maxn,ans);
return ;
}
int main()
{
scanf("%d%d",&r,&c);
for (int i=1;i<=r;i++)
for (int j=1;j<=c;j++)
{
scanf("%d",&a[i][j]);
book[i][j]=-1;
if (a[i][j]>maxx)
maxx=a[i][j];
}
for (int i=1;i<=r;i++)
for (int j=1;j<=c;j++)
{
dfs(i,j,1);
if (maxn==r*c)
{
printf("%d",r*c);
return 0;
}
}
printf("%d",maxn);
return 0;
}
不加o2第二个点也过不了,仅供参考