For this problem really is a little idea, do not know where to start ...
Or the Great White Question (P52), there is a detailed explanation.
The book says that the upper and lower bounds of the enumeration refer to the number of different ordinate values in total, because the coordinates given in the topic are integers, and each ordinate value can be a boundary, so there is only a finite combination.
One of the first areas of confusion is why the rectangles you find are special rectangles----parallel to the axes. Worth thinking about.
#include <cstdio>#include<cstring>#include<algorithm>using namespacestd;Const intMAXN = the; typedefLong LongLL;structpoint{intx; inty; FriendBOOL operator<(Point A,point b) {returna.x<b.x; }}A[MAXN];intY[MAXN],ON[MAXN],ON2[MAXN],LEFT[MAXN];intSolveintN) { intm = Unique (y,y+n)-y; if(m<=2)returnN; intAns =0; for(intLow =0; low<m;++low) for(intup = low+1; up<m;++Up ) { intYlow = Y[low],yup = Y[up],k =0; for(inti =0; i<n;++i) {if(i==0|| a[i].x!=a[i-1].x) {k++; ON[K]= On2[k] =0; if(k==1) Left[k] =0; ElseLeft[k] = left[k-1]+on2[k-1]-on[k-1]; } if(A[i].y>ylow && A[i].y<yup) on[k]++; if(A[i].y>=ylow && A[i].y<=yup) on2[k]++; } if(k<=2)returnN; intt =0; for(inti =1; i<=k;++i) {ans= Max (ans,left[i]+on2[i]+t); T= Max (t,on[i]-Left[i]); } } returnans;}intMain () {//freopen ("In.txt", "R", stdin); intN,kase =0; while(~SCANF ("%d", &n) &&N) { for(inti =0; i<n;++i) {scanf ("%d%d",&a[i].x,&a[i].y); Y[i]=a[i].y; } sort (Y,y+N); Sort (A,a+N); printf ("Case %d:%d\n",++kase,solve (n)); } return 0;}
LA3695 Distant Galaxy