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 |
这样不行吗?几乎和人家写的一样了#include"stdio.h" int map[102][102],result[102][102],tall,wide,max,sec[4][2]={-1,0,1,0,0,-1,0,1}; void cal(int x,int y){ int a,b,i; for(i=0;i<4;i++){ a=x+sec[i][0]; b=y+sec[i][1];//Éè×ø±ê if(map[a][b]<map[x][y]&&result[a][b]<result[x][y]+1){ result[a][b]=result[x][y]+1; if(max<result[a][b])max=result[a][b]; cal(a,b); } } } int main(){ int i,j,big_x,big_y,big; scanf("%d %d",&tall,&wide); for(i=1;i<=tall;i++){ for(j=1;j<=wide;j++){ scanf("%d",&map[i][j]); result[i][j]=0; } }//first for(i=0;i<=tall+1;i++){ map[i][0]=10001;map[i][wide+1]=10001; } for(i=0;i<=wide+1;i++){ map[0][i]=10001;map[tall+1][i]=10001; } max=1; while(1){ big=-1; for(i=1;i<=tall;i++) for(j=1;j<=wide;j++) if(result[i][j]==0&&map[i][j]>=big){ big_x=i; big_y=j; big=map[i][j]; } if(big==-1)break; result[big_x][big_y]=1; cal(big_x,big_y); }//while 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