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 |
测试了各种数据都没错,可一提交咋就WA啊?求大虾指点啊?#include<stdio.h> int dp[101][101]={0}; int r[101][101]={0}; int main() { int search(int i,int j,int m,int n); int m,n,i,j; // scanf("%d %d",&m,&n); while(scanf("%d %d",&m,&n)!=EOF) { for(i=0;i<m;i++) for(j=0;j<n;j++) { r[i][j]=0; scanf("%d",&dp[i][j]); } int max=0,temp; for(i=0;i<m;i++) for(j=0;j<n;j++) { temp=search(i,j,m,n); if(temp>max) max=temp; } printf("%d\n",max); } return 1; } int search(int i,int j,int m,int n) { if(r[i][j])// return r[i][j]; int temp[4],max=0; if(i+1<m&&dp[i+1][j]<dp[i][j]) temp[0]=search(i+1,j,m,n); if(i-1>=0&&dp[i-1][j]<dp[i][j]) temp[1]=search(i-1,j,m,n); if(j+1<n&&dp[i][j+1]<dp[i][j]) temp[2]=search(i,j+1,m,n); if(j-1>=0&&dp[i][j-1]<dp[i][j]) temp[3]=search(i,j-1,m,n); for(int k=0;k<4;k++) if(temp[k]>max) max=temp[k]; r[i][j]=max+1; return r[i][j]; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator