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

数据加了么?怎么我的k*b^2的垃圾算法TLE,后来改成(n-b)^2*b^2也是TLE?怎么回事呢?还望高手指教!

Posted by testdirk at 2007-02-10 19:04:55 on Problem 2019
In Reply To:这题目数据太弱了,K*B^2的算法都可以过,强烈要求hawk加数据~~ Posted by:forgotten at 2006-08-14 14:05:28
//		2019-----------------CornFields
#include<stdio.h>
int main(void)
{
	int n,b,k;
	int square[251][251],maxArray[251][251],minArray[251][251],answers[1001];
	int i,j,m,l,upRow,leftColumn;
	scanf("%d %d %d",&n,&b,&k);
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		{
			scanf("%d",&square[i][j]);
		}
	for (i=1;i<=n-b+1;i++)
		for (j=1;j<=n-b+1;j++)
		{
			maxArray[i][j]=-1;
			minArray[i][j]=251;
		}
	for (i=1;i<=n-b+1;i++)
		for (j=1;j<=n-b+1;j++)
			for (m=i;m<=i+b-1;m++)
				for (l=j;l<=j+b-1;l++)
				{
					if (square[m][l]<minArray[i][j]) minArray[i][j]=square[m][l];
					if (square[m][l]>maxArray[i][j]) maxArray[i][j]=square[m][l];
				}
	for (i=1;i<=k;i++)
	{
		scanf("%d %d",&upRow,&leftColumn);
		printf("%d\n",maxArray[upRow][leftColumn]-minArray[upRow][leftColumn]);
	}
}

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