Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么在WWW.VIJOS.CN都能过,而在这里就TLE#include<stdio.h> long n,m,a[200][200],b[200][200],c[10][10]; void dog(long x,long y) { long i; for (i=1;i<=4;i++) if (a[x][y]>a[x+c[i][1]][y+c[i][2]]) if (x+c[i][1]>0) if (x+c[i][1]<=n) if (y+c[i][2]>0) if (y+c[i][2]<=m) if (b[x][y]+1>b[x+c[i][1]][y+c[i][2]]) { b[c[i][1]+x][c[i][2]+y]=b[x][y]+1; dog(x+c[i][1],y+c[i][2]); } } int main() { long i,j,max; scanf("%d%d",&n,&m); for (i=1;i<=n;i++) for(j=1;j<=m;j++) { scanf("%d",&a[i][j]); b[i][j]=1; } c[1][1]=1; c[1][2]=0; c[2][1]=-1; c[2][2]=0; c[3][1]=c[4][1]=0; c[3][2]=-1; c[4][2]=1; for (i=1;i<=n;i++) for (j=1;j<=m;j++) dog(i,j); max=0; for (i=1;i<=n;i++) for (j=1;j<=m;j++) if (max<b[i][j]) max=b[i][j]; printf("%d\n",max); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator