Topic links: https://nanti.jisuanke.com/t/41393
Title effect: analysis n points, plus a minimum number of points Q such that the center point of symmetry.
answer:
Two point may determine a center point, O (n ^ 2) enumeration central point, provided cnt [Xc] [Yc] of the center point (Xc, Yc) are pieces
For the number of times,
Then the center point (Xc, Yc), the number of points required to make up the n-2 * cnt [Xc] [Yc] - (point (Xc, Yc) in the original
The number of points in the set appears),
You can map or a hash value cnt recording.
In addition, if the input coordinates are multiplied by 2, then to enumerate the coordinates of the center point on all the integers.
#include<bits/stdc++.h> using namespace std; typedef long long ll; struct st{ ll x,y; }stm[1005]; map<ll,int> mp; map<ll,int> mp1; set<ll> se; const ll tem=1e7; queue<ll> que; map<ll,int> vis; int main(){ int n; scanf("%d",&n); int maxs=0; for(int i=0;i<n;i++){ scanf("%lld%lld",&stm[i].x,&stm[i].y); stm[i].x*=2; stm[i].y*=2; ll tt=stm[i].x*tem+stm[i].y; mp[tt]++; } for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i<j){ ll tt=(stm[i].x+stm[j].x)/2*tem+(stm[i].y+stm[j].y)/2; int count=++mp1[tt]; if(count>maxs){ maxs=count; while(!que.empty())que.pop(); que.push(tt); } else if(count==maxs){ que.push(tt); } } } } int= ANS n-; the while (! que.empty ()) { LL TT = que.front (); que.pop (); ANS = min (ANS, n--MP1 [TT] * 2 - (MP [TT] & . 1 )); IF (MP [TT] & . 1 ) BREAK ; // COUT TT << << endl; } for ( int I = 0 ; I <n-; I ++) { // consider the case where the center point at the origin ll STM = TT [I] .x + * TEM STM [I] .y; ANS = min (ANS, n--MP1 [TT] * 2 - (MP [TT] & . 1 )); } the printf ( "%d\n",ans); return 0; }