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 original[100][100]={-1}; int record[100][100]={-1}; int row,col; int DP(int i,int j) { int max=0; if (record[i][j]>=0) return record[i][j]; if ((i-1>=0)&&(original[i][j]>=original[i-1][j])) { if(max<DP(i-1,j)) { max=DP(i-1,j); } } if ((i+1<=row-1)&&(original[i][j]>=original[i+1][j])) { if(max<DP(i+1,j)) { max=DP(i+1,j); } } if ((j-1>=0)&&(original[i][j]>=original[i][j-1])) { if(max<DP(i,j-1)) { max=DP(i,j-1); } } if ((j+1<=col-1)&&(original[i][j]>=original[i][j+1])) { if(max<DP(i,j+1)) { max=DP(i,j+1); } } return record[i][j]=max+1; } int main() { int i,j,result; scanf("%d%d",&row,&col); for (i=0;i<row;i++) for(j=0;j<col;j++) scanf("%d",&original[i][j]); for (i=0;i<row;i++) for(j=0;j<col;j++) record[i][j]=DP(i,j); for (i=0;i<row;i++) for(j=0;j<col;j++) if (record[i][j]>result) result=record[i][j]; printf("%d",result); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator