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

高手帮忙啊! 那组经典数据都过了 还是WA啊啊啊啊啊啊

Posted by ysj16 at 2010-03-02 21:30:04 on Problem 1088
#include<stdio.h>
#include<string.h>
int arr[110][110];
int rec[110][110];
int main()
{
	int max(int,int);
	int i,j,bmax;
	int r,c;
    scanf("%d %d",&r,&c); 

	for(i=0;i<110;i++)
		for(j=0;j<110;j++)
		{
			arr[i][j]=-1;
			rec[i][j]=-1;
		}
	
		bmax=0;
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++)
			scanf("%d",&arr[i][j]);
	for(i=1;i<=r;i++)
		for(j=1;j<=c;j++)
		{
			if(max(i,j)>bmax)
				bmax=rec[i][j];
		}
		printf("%d\n",bmax);
		return 0;

}
int max(int n,int m)
{
	int amax=0;
	if(arr[n][m]<=arr[n+1][m]&&arr[n][m]<=arr[n-1][m]&&arr[n][m]<=arr[n][m+1]&&arr[n][m]<=arr[n][m-1])
		return 1;
	if(rec[n][m]!=-1) return rec[n][m];
	if(arr[n+1][m]<arr[n][m] && arr[n+1][m]>=0)
		if(max(n+1,m)>amax) 
			amax=rec[n+1][m];
	if(arr[n-1][m]<arr[n][m] && arr[n-1][m]>=0)
		if(max(n-1,m)>amax)
			amax=rec[n-1][m];
	if(arr[n][m+1]<arr[n][m] && arr[n][m+1]>=0)
		if(max(n,m+1)>amax)
			amax=rec[n][m+1];
	if(arr[n][m-1]<arr[n][m] && arr[n][m-1]>=0)
		if(max(n,m-1)>amax)
			amax=rec[n][m-1];
		rec[n][m]=amax+1;
		return amax+1;
}

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