zoukankan      html  css  js  c++  java
  • 2019ACM-ICPC徐州网络赛-K- Center(简单贪心+map)

    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-ans);
    29     return 0;
    30 }
  • 相关阅读:
    HDU 4334
    HDU 1280
    HDU 1060
    HDU 4033
    大三角形分成4个面积相等的小三角形
    HDU 1087
    HDU 4313
    Sleep(0)及其使用场景
    Decorator(装饰、油漆工)对象结构型模式
    Debug Assertion Failed!
  • 原文地址:https://www.cnblogs.com/CharlieWade/p/11482576.html
Copyright © 2011-2022 走看看