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:大家来找错············为什么WA?请NB人看一下In Reply To:大家来找错············为什么WA?请NB人看一下 Posted by:ruanshaomin at 2009-08-23 18:34:25 > #include<stdio.h> > #include<stdlib.h> > int height[105][105]; > int len[10005]={0}; > int R,C; > struct node > { > int i; > int j; > int b; > }h[10005]; > int cmp(const void *e1,const void *e2) > { > struct node *pe1 = (struct node *)e1; > struct node *pe2 = (struct node *)e2; > return pe1->b - pe2->b; > } > > int f(int a,int q) > { > int t1=h[q].i; > int t2=h[q].j; > int flag=0; > int d[5]={0}; > if(a>height[t1][t2+1]) > { > d[1]=len[height[t1][t2+1]]+1; > flag=1; > } > if(a>height[t1][t2-1]) > { > d[2]=len[height[t1][t2-1]]+1; > flag=1; > } > if(a>height[t1+1][t2]) > { > d[3]=len[height[t1+1][t2]]+1; > flag=1; > } > if(a>height[t1-1][t2]) > { > d[4]=len[height[t1-1][t2]]+1; > flag=1; > } > int max=0; > if(flag==1) > { > int k; > for(k=1;k<=4;k++) > if(max<d[k]) > max=d[k]; > } > return max+1; > } > > int main() > { > int i,j,k,q; > for(i=0;i<105;i++) > for(j=0;j<105;j++) > height[i][j]=50005; > scanf("%d %d",&R,&C); > k=1; > for(i=1;i<=R;i++) > for(j=1;j<=C;j++) > { > scanf("%d",&height[i][j]); > h[k].b=height[i][j]; > h[k].i=i; > h[k].j=j; > k++; > } > k--; > qsort(&h[1],k,sizeof(h[1]),cmp); > > for(q=1;q<=k;q++) > len[h[q].b]=f(h[q].b,q); > > int max=0; > for(i=1;i<=k;i++) > if(max<len[h[i].b]) > max=len[h[i].b]; > printf("%d\n",max); > > } > > > > > > > > > Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator