LA3695 Distant Galaxy

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.