If, without the translation of purple books, I think I may not understand the problem. =_=||
Test instructions
There are n points on the plane, not white dots or black dots. Now put a straight line so that the white point on one side of the line and the black point on the other side add up to the highest number. A point on a line can be considered to be on either side of a line.
Analysis:
First assume that the line passes through two points, otherwise you can move the line so that it passes through two points, and the total is not reduced.
So, we can enumerate a base point first and then focus on that point.
The other points are sorted by the polar angle around the base point, the lines are rotated, and the number of points that meet the requirements is counted.
Tips:
If all black dots are centered at the base point, the number of points that meet the requirement becomes the number of points on one side of the line.
1#include <bits/stdc++.h>2 3 using namespacestd;4 5 Const intMAXN = ++Ten;6 7 intN, COLOR[MAXN];8 9 struct PointTen { One intx, y; APoint (intx=0,inty=0): X (x), Y (y) {} - DoubleRad; - BOOL operator< (Constpoint& RHS)Const the{returnrad <Rhs.rad;} - }OP[MAXN], P[MAXN]; - -Pointoperator- (Constpoint& A,Constpoint&B) +{returnPoint (a.x-b.x, a.y-b.y); } - + intCross (Constpoint& A,Constpoint&B) A{returna.x*b.y-a.y*b.x;} at - intSolve () - { - //if (n <= 3) return n; - intAns =0; - for(inti =0; I < n; ++i) in{//Enumerate base points - intK =0; to for(intj =0; J < N; ++J)if(I! =j) + { -P[K] = op[j]-Op[i]; the if(Color[j]) {p[k].x =-p[k].x; p[k].y =-p[k].y;}//a central symmetry of the black dots. *P[k].rad =atan2 (P[K].Y, p[k].x); $k++;Panax Notoginseng } -Sort (p, p+k); the + intL =0, R =0, cnt =2; A for(; L < K; ++L) the{//statistics P[l] to P[r] points + if(L = = R) {R = (r+1)%k; cnt++; } - while(L! = R && Cross (P[l], p[r]) >=0) {R = (r+1)%k; cnt++; }//when the interval is greater than 180 degrees, stop $cnt--; $Ans =max (ans, CNT); - } - } the returnans; - }Wuyi the intMain () - { WuFreopen ("In.txt","R", stdin); - About while(SCANF ("%d", &n) = =1&&N) $ { - for(inti =0; I < n; ++i) scanf ("%d%d%d", &op[i].x, &OP[I].Y, &color[i]); -printf"%d\n", Solve ()); - } A + return 0; the}
code June
UVa 1606 (extreme angle sort) amphiphilic Carbon molecules