Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:测试了各种数据都没错,可一提交咋就WA啊?求大虾指点啊?

Posted by lanshanxunmeng at 2012-07-06 20:17:10 on Problem 1088
In Reply To:测试了各种数据都没错,可一提交咋就WA啊?求大虾指点啊? Posted by:lanshanxunmeng at 2012-07-06 20:01:51
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator