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

改了一下 pass 不过还可以在改进一些

Posted by first at 2003-12-11 19:24:41 on Problem 1088
#include <iostream>
using namespace std;
const int x[4]={1,-1,0,0},y[4]={0,0,1,-1};
void main()
{
    int rep,i,j,p,r,c,a[100][100],l[100][100];
	unsigned min=-1,max=0;
    cin>>r>>c;
    for(i=0;i<r;i++)
		for(j=0;j<c;j++)
		{
		 cin>>a[i][j];
		 min=min>a[i][j]?a[i][j]:min;
		 max=max<a[i][j]?a[i][j]:max;
		}
		memset (l,0,100*100*sizeof(int));
	      for(;;)
		  {
		      for(i=0;i<r;i++)
				for(j=0;j<c;j++)
				{
					if(min==a[i][j])
					for(p=0;p<4;p++)
						if(i+x[p]>=0&&i+x[p]<r&&j+y[p]>=0&&j+y[p]<c)
							if((a[i][j]-a[i+x[p]][j+y[p]]>0)&&(l[i][j]<l[i+x[p]][j+y[p]]+1))
							{
							l[i][j]=l[i+x[p]][j+y[p]]+1;rep=1;
							}
				}
				min++;
				if(min==max+1)
					break;
		  }
		rep=0;
		for(i=0;i<r;i++)
			for(j=0;j<c;j++)
			 if(l[i][j]>rep)
			  rep=l[i][j];
	 	cout<<rep+1<<endl;
}

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