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

为什么我得不出答案 头大了,想不清楚了,不知哪里错了,可有高人帮忙看看我的代码,感谢

Posted by moonqqqq at 2009-03-24 12:06:35 on Problem 1088
#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:
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