Enumerate each vertex for rotation, sort by polar angle, scan once, and get the result.
# Include <iostream> # include <cstdio> # include <cstring> # include <algorithm> # include <cmath> # define PI 3.14159265359 # define EPS 1e-8using namespace STD; struct point {int X, Y, R; double Ang;} REM [1005], V [1005]; int N; int CMP (const struct point A, const struct point B) // sort by angle (polar angle) {if (. ang <B. ang) return 1; else return 0;} int sig (double A) // determine whether the current precision is 0. If the precision 0 is satisfied, 1 is not satisfied,-1 is equal to the precision {If (FABS () <EPS) return 0; else if (a> 0) return 1; else return-1;} int cross (struct point A, struct point B, struct point C) // Cross Product {return (B. x-. x) * (C. y-. y)-(C. x-. x) * (B. y-. y);} int main () {While (scanf ("% d", & N) {int ans = 0; For (INT I = 1; I <= N; ++ I) {scanf ("% d", & V [I]. x, & V [I]. y, & V [I]. r); REM [I] = V [I]; // REM stores the most primitive data} For (INT I = 1; I <= N; ++ I) // ***** enumerate the rotation points of each vertex {for (Int J = 1; j <= N; ++ J) // assign values to vertices whose values are 0. assign values directly to vertices whose values are 1 and symmetric values. calculation angle {v [J] = REM [J]; If (V [J]. R = 1) // if the property is 1, The point is symmetric to the other end of the line {v [J]. X = REM [I]. x * 2-V [J]. x; V [J]. y = REM [I]. y * 2-V [J]. y;} V [J]. ang = atan2 (V [J]. y-REM [I]. y, V [J]. x-REM [I]. x); // calculate radians} swap (V [I], V [1]); // v [1] is always the point of the current enumeration, so the value of V [I] is constantly exchanged with the value of V [1] Sort (V + 2, V + n + 1, CMP); // ***** polar sorting // start point, which already has two, V [1] and V [2] Then consider the third point for (int s = 2, T = 3; S <= N & sig (V [s]. ang) <= 0; s ++) // ***** the current line is determined by V [1] and V [s] (select a straight line and rotate the scan) {int on = 2; // on is the number of points on a straight line for (; t <= N & cross (V [1], V [s], V [T])> = 0; t ++) // only judge the vertices on one side. t counts the vertices on one side {If (Cross (V [1], V [s], V [T]) = 0) // three-point collinearity in ICPC online on ++; // online point + 1} // t-s-1: the value N-(t-s + 1) + on the 0-side solution, the 0-side solution, and the 0 ans = max (ANS, max (t-s + 1, N-(t-s + 1) + on);} printf ("% d \ n", ANS );} return 0 ;}