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 main() { int i,j,max=0,r,c,k=0,temp,temp1,a[105][105],fin[105][105],r1[10005],l1[10005],len[10005]; scanf("%d %d",&r,&c); for(i=1;i<=r;i++) for(j=1;j<=c;j++) scanf("%d",&a[i][j]); for(i=1;i<=r;i++) { fin[i][0]=0; fin[i][c+1]=0; } for(j=1;j<=c;j++) { fin[0][j]=0; fin[r+1][j]=0; } for(i=1;i<=r;i++) { for(j=1;j<=c;j++) { k++; len[k]=a[i][j]; r1[k]=i; l1[k]=j; } } for(i=1;i<=k-1;i++) { for(j=i+1;j<=k;j++) { if(len[i]>len[j]) { temp=len[i]; len[i]=len[j]; len[j]=temp; temp=r1[i]; r1[i]=r1[j]; r1[j]=temp; temp=l1[i]; l1[i]=l1[j]; l1[j]=temp; } } } for(i=1;i<=k;i++) { temp=a[r1[i]][l1[i]]; temp1=fin[r1[i]][l1[i]]; if(a[r1[i]][l1[i]+1]<temp&&fin[r1[i]][l1[i]+1]>temp1) temp1=fin[r1[i]][l1[i]+1]; if(a[r1[i]-1][l1[i]]<temp&&fin[r1[i]-1][l1[i]]>temp1) temp1=fin[r1[i]-1][l1[i]]; if(a[r1[i]+1][l1[i]]<temp&&fin[r1[i]+1][l1[i]]>temp1) temp1=fin[r1[i]+1][l1[i]]; if(a[r1[i]][l1[i]-1]<temp&&fin[r1[i]][l1[i]-1]>temp1) temp1=fin[r1[i]][l1[i]-1]; fin[r1[i]][l1[i]]=temp1+1; } max=fin[1][1]; for(i=1;i<=r;i++) { for(j=1;j<=c;j++) { if(fin[i][j]>max) max=fin[i][j]; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator