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!求高手帮忙看看……不胜感激!In Reply To:讨论区的所有测试数据都过了,提交还是WA!求高手帮忙看看……不胜感激! Posted by:adetwo at 2010-07-14 17:23:01 > #include<stdio.h> > > int rc[105][105]; > int result[105][105]; > > int setD(int row,int col) > { > int value[4]={1,1,1,1},max; > if(result[row][col]!=0) > return result[row][col]; > else > { > max = 1; > if(rc[row-1][col]<rc[row][col]) > value[0]=setD(row-1,col)+1; > > if(rc[row][col-1]<rc[row][col]) > value[1]=setD(row,col-1)+1; > > if(rc[row][col+1]<rc[row][col]) > value[2]=setD(row,col+1)+1; > > if(rc[row+1][col]<rc[row][col]) > value[3]=setD(row+1,col)+1; > > for(int k=0;k<4;k++) > if(value[k]>max) > max=value[k]; > result[row][col]=max; > return max; > } > } > > int main() > { > // freopen("input.txt","r",stdin); > int i,j,r,c,max; > scanf("%d %d",&r,&c); > > for(j=0;j<c+2;j++) > { > rc[0][j]=10001; > rc[r+1][j]=10001; > } > for(i=1;i<r+1;i++) > { > rc[i][0]=10001; > rc[i][c+1]=10001; > } > for(i=1;i<r+1;i++) > for(j=1;j<c+1;j++) > scanf("%d",&rc[i][j]); > > for(i=1;i<r+1;i++) > for(j=1;j<c+1;j++) > setD(i,j); > > max=0; > for(i=1;i<r+1;i++) > for(j=1;j<c+1;j++) > { > if(result[i][j]>max) > max=result[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