Two points + greedy
The first two points L, converted into a judgment problem ...
But the verdict won't be sentenced, Qaq.
Orz Hzwer, with a minimal rectangular frame, the residence is a bit, straight toward the corner of the rectangle square ... The second one was set in the same way, and the rest could be completely covered.
I have to say that Hzwer's approach is understood ...
1 /**************************************************************2 problem:10523 User:tunix4 language:c++5 result:accepted6 time:308 Ms7 memory:1512 KB8 ****************************************************************/9 Ten //Bzoj 1052 One#include <vector> A#include <cstdio> -#include <cstring> -#include <cstdlib> the#include <iostream> -#include <algorithm> - #defineRep (i,n) for (int i=0;i<n;++i) - #defineF (i,j,n) for (int i=j;i<=n;++i) + #defineD (i,j,n) for (int i=j;i>=n;--i) - #definePB Push_back + using namespacestd; AInlineintGetint () { at intv=0, sign=1;CharCh=GetChar (); - while(ch<'0'|| Ch>'9'){if(ch=='-') sign=-1; Ch=GetChar ();} - while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} - returnv*Sign ; - } - Const intn=20010, inf=1e9; intypedefLong LongLL; - /******************tamplate*********************/ to intN,l,mid; + structdata{intX[n],y[n],top;} A; - voidCut (Data &a,intX1,intY1,intX2,inty2) { the inttot=0; *F (I,1, A.top) $ if(a.x[i]<x1 | | a.x[i]>x2 | | a.y[i]<y1 | | a.y[i]>y2) {Panax Notoginsengtot++; -a.x[tot]=A.x[i]; thea.y[tot]=A.y[i]; + } Aa.top=tot; the } + voidSolve (data &a,intFC) { - intx1=inf,y1=inf,x2=-inf,y2=-INF; $F (I,1, A.top) { $X1=min (a.x[i],x1), x2=Max (a.x[i],x2); -Y1=min (a.y[i],y1), y2=Max (a.y[i],y2); - } the if(fc==1) Cut (a,x1,y1,x1+mid,y1+mid); - if(fc==2) Cut (a,x2-mid,y1,x2,y1+mid);Wuyi if(fc==3) Cut (a,x1,y2-mid,x1+mid,y2); the if(fc==4) Cut (a,x2-mid,y2-mid,x2,y2); - } Wu BOOLjudge () { - data b; AboutF (x,1,4) F (Y,1,4){ $b.top=A.top; -F (I,1, B.top) -b.x[i]=a.x[i],b.y[i]=A.y[i]; - solve (b,x); solve (b,y); A intx1=inf,y1=inf,x2=-inf,y2=-INF; +F (I,1, B.top) { theX1=min (b.x[i],x1), x2=Max (b.x[i],x2); -Y1=min (b.y[i],y1), y2=Max (b.y[i],y2); $ } the if(X2-x1<=mid && Y2-y1<=mid)return 1; the } the return 0; the } - intMain () { in #ifndef Online_judge theFreopen ("1052.in","R", stdin); theFreopen ("1052.out","W", stdout); About #endif theN=getint (); a.top=N; theF (I,1, n) a.x[i]=getint (), a.y[i]=getint (); the intL=1, r=INF; + while(l<=R) { -Mid=l+r>>1; the if(Judge ()) l=mid,r=mid-1;Bayi ElseL=mid+1; the } theprintf"%d\n", L); - return 0; -}View Code 1052: [HAOI2007] Overwrite issue time limit:10 Sec Memory limit:162 MB
submit:1181 solved:534
[Submit] [Status] [Discuss] Description
Someone planted n small saplings on the mountain. Winter came, the temperature dropped rapidly, the small saplings fragile vulnerable, so the tree owners want to use some plastic film to cover up these small trees, after a long thought, he decided to use 3 l*l square plastic film to cover up the small trees. We may as well set up a plane Cartesian coordinate system, set the coordinates of the small tree I (xi,yi), The edge of the 3 l*l square is required to parallel with the axis, a point if on the boundary of the square, also counted as covered. Of course, we hope that the smaller the plastic film area, the better, that is, the L minimum value.
Input
The first line has a positive integer n, which indicates how many trees there are. Next there are n rows, and the i+1 line has 2 integer xi,yi, which represents the coordinates of the tree I, guaranteeing that no 2 trees have the same coordinates.
Output
A row that outputs the minimum L value.
Sample Input4
0 1
0-1
1 0
-1 0Sample Output1HINT
100% of data, n<=20000
Source [Submit] [Status] [Discuss]
"Bzoj" "1052" "HAOI2007" coverage issues