Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
数据加了么?怎么我的k*b^2的垃圾算法TLE,后来改成(n-b)^2*b^2也是TLE?怎么回事呢?还望高手指教!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator