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

请求高手指导 为什么我的1088题代码始终WA 谢谢

Posted by justinaicc at 2011-01-06 10:36:10 on Problem 1088
代码如下 始终WA
#include<stdio.h>
int C, R, a[100][100], cnt[100][100];
int f(int h, int i, int j)
{
	int m = 0;
	if(cnt[i][j] > 0) return cnt[i][j];
	if(a[i-1][j]<h && i-1>=0)
		if(f(a[i-1][j], i-1, j)>m)
			m = f(a[i-1][j], i-1, j);
	if(a[i][j+1]<h && j+1<R)
		if(f(a[i][j+1], i, j+1)>m)
			m = f(a[i][j+1], i, j+1);
	if(a[i+1][j]<h && i+1<C)
		if(f(a[i+1][j], i+1, j)>m)
			m = f(a[i+1][j], i+1, j);
	if(a[i][j-1]<h && j-1>=0)
		if(f(a[i][j-1], i, j-1)>m)
			m = f(a[i][j-1], i, j-1);
	return cnt[i][j] = m + 1;

}
int main()
{
	int i, j, x, y, max = 0;
	scanf("%d%d", &C, &R);
	for(i=0; i<C; i++)
		for(j=0; j<R; j++)
		{
			scanf("%d", &a[i][j]);
			cnt[i][j] = 0;
		}

	for(i=0; i<C; i++)
	{
		for(j=0; j<R; j++)
		{
			if(a[i][j] > max)
			{
				max = a[i][j];
				x = i;
				y = j;
			}
		}
	}

	printf("%d\n", f(a[x][y], x, y));
	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