2019ACM-ICPC徐州网络赛-K- Center(简单贪心+map)

本文探讨了在二维平面上,如何通过增加最少数量的点,使得给定点集中的所有点都成为中心对称。中心对称意味着存在一个中心点,使得每一点都有一个对应的点满足中心对称条件。文章提供了算法思路和实现代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

K- Center

2000ms     262144K

You are given a point set with nn points on the 2D-plane, your task is to find the smallest number of points you need to add to the point set, so that all the points in the set are center symmetric.

All the points are center symmetric means that you can find a center point (X_c,Y_c)(Xc,Yc)(not necessarily in the point set), so that for every point (X_i,Y_i)(Xi,Yi) in the set, there exists a point (X_j,Y_j)(Xj,Yj) (ii can be equal to jj) in the set satisfying X_c=(X_i+X_j)/2Xc=(Xi+Xj)/2 and Y_c=(Y_i+Y_j)/2Yc=(Yi+Yj)/2.

Input

The first line contains an integer n(1 \le n \le 1000)n(1n1000).

The next nn lines contain nn pair of integers (X_i,Y_i)(Xi,Yi(-10^6 \le X_i,Y_i \le 10^6)(106Xi,Yi106) -- the points in the set

Output

Output a single integer -- the minimal number of points you need to add.

样例输入
3
2 0
-3 1
0 -2
样例输出
1
样例解释

For sample 11, add point (5,-3)(5,3) into the set, the center point can be (1,-1)(1,1) .

 1 #include <bits/stdc++.h>
 2 #pragma GCC optimize(3)
 3 using namespace std;
 4 typedef long long ll;
 5 typedef pair<int,int> PII;
 6 const int maxn=1e6+7;
 7 map<PII,int>MAP;
 8 int x[maxn],y[maxn];
 9 int main()
10 {
11     int n;
12     int ans=0;
13     scanf("%d",&n);
14     for(int i=1;i<=n;++i)
15     {
16         scanf("%d%d",&x[i],&y[i]);
17         x[i]*=2;
18         y[i]*=2;
19     }
20     for(int i=1;i<=n;++i)
21     {
22         for(int j=1;j<=n;++j)
23         {
24             int a=++MAP[PII((x[i]+x[j])/2,(y[i]+y[j])/2)];
25             if(a>ans)ans=a;
26         }
27     }
28     printf("%d\n",n-ans);
29     return 0;
30 }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值