POJ 2280&&hdu 1661

Source: Internet
Author: User

Test instructions: N points on a given plane, the attributes are labeled 0 and 1, then a line is found, all the points on the line are dissolved, 1 dissolves on one side, and 0 dissolves on the other. Find out the maximum number of points that can be dissolved.

Idea: Violent enumeration of each point, scan line rotation. To do the optimization first, if the side dissolves 0, then the property is 1 to do about the current enumeration line symmetry point, so that the point on the statistic side plus the point on the line is the answer. O (n2).

1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5#include <Set>6#include <stdio.h>7#include <stdlib.h>8#include <math.h>9 #defineCLC (A, B) memset (A,b,sizeof (a))Ten #defineEPS 1e-8 OnetypedefLong LongLL; A Const intMod=47000; - Const intinf=0x3f3f3f3f; - using namespacestd; the #defineN 100010 -  - structnode - { +     intX,y,r; -     Doubleang; +}v[1010],rem[1010]; A  at intcmpConst structNode A,Const structNode B) - { -     if(a.ang<B.ang) -         return 1; -     Else -         return 0; in } -  to intSIG (Doublea) + { -     if(Fabs (a) <EPS) the         return 0; *     Else if(a>0) $         return 1;Panax Notoginseng     Else -         return-1; the } +  A intCrossstructNode A,structNode B,structnode C) the { +     return(b.x-a.x) * (C.Y-A.Y)-(c.x-a.x) * (b.y-a.y); - } $  $ intMain () - { -     intN; the      while(~SCANF ("%d", &n) &&N) -     {Wuyi         intans=0; the          for(intI=0; i<n;i++) -         { Wuscanf"%d%d%d",&v[i].x,&v[i].y,&V[I].R); -rem[i]=V[i]; About         } $          for(intI=0; i<n;i++) -         { -              for(intj=0; j<n;j++) -             { Av[j]=Rem[j]; +                 if(v[j].r==1) the                 { -v[j].x=rem[i].x*2-v[j].x; $v[j].y=rem[i].y*2-v[j].y; the                 } theV[j].ang=atan2 (v[j].y-rem[i].y,v[j].x-rem[i].x); the             } theSwap (v[i],v[0]); -Sort (v+1, v+n,cmp); in              for(intj=1, t=2; J<n&&sig (V[j].ang) <=0; j + +) the             { the                 inton=2; About                  for(; T<n&&cross (v[0],v[j],v[t]) >=0; t++) the                 { the                     if(Cross (v[0],v[j],v[t]) = =0) theon++; +                 } -Ans=max (Ans,max (t-j+1, N-(t-j+1)+on )); the             }Bayi         } thecout<<ans<<Endl; the     } -     return 0; -}
View Code

POJ 2280&&hdu 1661

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.