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

Re:为什么在WWW.VIJOS.CN都能过,而在这里就TLE

Posted by haozhanzhu at 2009-07-26 16:18:27 on Problem 1088
In Reply To:为什么在WWW.VIJOS.CN都能过,而在这里就TLE Posted by:oi111 at 2009-07-24 10:43:26
> #include<stdio.h>
> long n,m,a[200][200],b[200][200],c[10][10];
> void dog(long x,long y)
> {
> 	long i;
> 	for (i=1;i<=4;i++)
>       if (a[x][y]>a[x+c[i][1]][y+c[i][2]])
> 		if (x+c[i][1]>0)
> 			if (x+c[i][1]<=n)
> 				if (y+c[i][2]>0)
> 					if (y+c[i][2]<=m)
> 							if (b[x][y]+1>b[x+c[i][1]][y+c[i][2]])
> 		{
> 			b[c[i][1]+x][c[i][2]+y]=b[x][y]+1;
> 			dog(x+c[i][1],y+c[i][2]);
> 		}
> }
> int main()
> {
> 	long i,j,max;
> 	scanf("%d%d",&n,&m);
> 	for (i=1;i<=n;i++)
> 		for(j=1;j<=m;j++)
> 		{
> 			scanf("%d",&a[i][j]);
> 			b[i][j]=1;
> 		}
> 	c[1][1]=1;
> 	c[1][2]=0;
> 	c[2][1]=-1;
> 	c[2][2]=0;
> 	c[3][1]=c[4][1]=0;
> 	c[3][2]=-1;
> 	c[4][2]=1;
> 	for (i=1;i<=n;i++)
> 		for (j=1;j<=m;j++)
> 			dog(i,j);
> 	max=0;
> 	for (i=1;i<=n;i++)
> 		for (j=1;j<=m;j++)
> 			if (max<b[i][j]) 
> 				max=b[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