[The Preliminary Contest for ICPC Asia Xuzhou 2019 - 徐州网络赛K] Center

Center

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(1≤n≤1000).

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)(−106≤Xi​,Yi​≤106) -- 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) .

 暴力枚举每个可能的中心,得到以该位置为中心的点对的个数。找出点最多的中心,答案即为点的总数减去以该中心为中心的点的个数。复杂度为O(n^2)。

#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e3;
struct Point
{
    int x, y;
    Point() {}
    Point(int x, int y): x(x), y(y) {}
    bool operator < (const Point& p) const
    {
        if(x != p.x)
            return x < p.x;
        return y < p.y;
    }
}p[maxn];
int n;
map<Point, int> m;

void read()
{
    cin >> n;
    int x, y;
    for(int i = 0; i < n; ++i)
    {
        cin >> x >> y;
        p[i] = Point(x<<1, y<<1);
    }
}

void solve()
{
    int ans = 0;
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j < n; ++j)
        {
            Point pc = Point((p[i].x+p[j].x)>>1, (p[i].y+p[j].y)>>1);
            if(!m.count(pc))
                m[pc] = 1;
            else
                ++m[pc];
            ans = max(m[pc], ans);
        }
    }
    cout << n - ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    read();
    solve();
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值