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 |
Re:分享本人写的猥琐代码。。。In Reply To:分享本人写的猥琐代码。。。 Posted by:euloanty at 2012-07-22 20:58:13 #include<stdio.h> int hh[100][100]; int r,c; int longf(int x,int y) { int max=0,mm=0; if(hh[x+1][y]<hh[x][y]&&x+1<r) mm=longf(x+1,y)+1; if(mm>max)max=mm; if(hh[x-1][y]<hh[x][y]&&x-1>=0) mm=longf(x-1,y)+1; if(mm>max)max=mm; if(hh[x][y+1]<hh[x][y]&&y+1<c) mm=longf(x,y+1)+1; if(mm>max)max=mm; if(hh[x][y-1]<hh[x][y]&&y-1>=0) mm=longf(x,y-1)+1; if(mm>max)max=mm; if(mm==0)return 1; else return max; } int main() { int i,j,max,ll,x,y; scanf("%d %d",&r,&c); for (i=0;i<r;i++) { for (j=0;j<c;j++) { scanf("%d",hh[i]+j); if(hh[i][j]>max) { max=hh[i][j]; x=i; y=j; } } } ll=longf(x,y); printf("%d\n",ll); return 0; } /* 5 5 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 25 */ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator