The Preliminary Contest for ICPC Asia Xuzhou 2019 K. Center

这题对于能加入最多边缘点的center点,这个点就是最优的center ,对于center点,总共是n^2的,顶多也就1e6,所以直接双重循环就行了, 然后map<pair,set >映射一下,第二个用set是因为虽然同一个中心点,对应的边缘点不会出现两次,但是题目中允许一个点作为边缘点两次 ,所以去重的是自己和自己相同的点。
最后输出以下答案就可以了。

#include <bits/stdc++.h>
using namespace std;

typedef pair<double,double> Pair;
map<Pair,set<Pair> >mp;
Pair p[1010];

#define pf(x) p[x].first
#define ps(x) p[x].second

int main()
{
	// ios::sync_with_stdio(false);
	int N;
	// cin>>N;
	scanf("%d",&N);
	for (int i=0;i<N;i++) {
		//cin>>pf(i)>>ps(i);
		scanf("%lf%lf",&pf(i),&ps(i));
	}
	
	int res=-1;
	for (int i=0;i<N;i++) {
		for (int j=i;j<N;j++) {
			Pair x=make_pair((pf(i)+pf(j))/2,(ps(i)+ps(j))/2);
			mp[x].insert(p[i]);
			mp[x].insert(p[j]);
			int size=mp[x].size();
			res=size>res?size:res;
		}
	}
	printf("%d\n",N-res);
	return 0;
}
posted @ 2019-10-23 11:29  xyee  阅读(128)  评论(0编辑  收藏  举报