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 sunpy at 2008-09-15 14:36:09 on Problem 1088
#include<stdio.h>
#define N 101

int len[N][N],a[N][N];
int r,c;
void find_min(int nos,int &s,int &t)
{
	int i,j,s1,t1,min=10001;
	for(i=0;i<r;i++)
		for(j=0;j<c;j++)
		{
			if(a[i][j]<nos || (i==s &&j==t))
				continue;
			if(min>a[i][j])
			{
				min=a[i][j];
				s1=i;
				t1=j;
			}
		}
	s=s1;
	t=t1;
}
int main()
{
	
	scanf("%d%d",&r,&c);
	int i,j,s,t;
	for(i=0;i<r;i++)
		for(j=0;j<c;j++)
		{
			scanf("%d",*(a+i)+j);
			len[i][j]=1;
		}
	s=t=100;
	a[s][t]=0;
	for(i=1;i<=r*c;i++)
	{
		find_min(a[s][t],s,t);
		if(s>0	&&	a[s-1][t]>a[s][t] && len[s-1][t]<=len[s][t])
			len[s-1][t]=len[s][t]+1;
		if(s<r-1 && a[s+1][t]>a[s][t] && len[s+1][t]<=len[s][t])
			len[s+1][t]=len[s][t]+1;
		if(t>0 && a[s][t-1] >a[s][t] &&len[s][t-1]<=len[s][t])
			len[s][t-1]=len[s][t]+1;
		if(t<c-1 && a[s][t+1]>a[s][t] && len[s][t+1]<=len[s][t])
			len[s][t+1]=len[s][t]+1;
	}
	int max=0;
	for(i=0;i<r;i++)
		for(j=0;j<c;j++)
			if(max<len[i][j])
				max=len[i][j];
	printf("%d\n",max);
	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