比赛 4043级NOIP2022欢乐赛2nd 评测结果 TTTTTTTTTT
题目名称 平面最近点对 最终得分 0
用户昵称 HeSn 运行时间 10.000 s
代码语言 C++ 内存使用 8.79 MiB
提交时间 2022-10-31 19:15:53
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 200010;
int n, xi[MAXN], yi[MAXN], ans;
int dis(int a, int b, int c, int d) {
	return (a - c) * (a - c) + (b - d) * (b - d);
}
signed main() {
	freopen("closest.in", "r", stdin);
	freopen("closest.out", "w", stdout);
	cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> xi[i] >> yi[i];
	}
	ans = 1e12;
	for(int i = 1; i <= n; i ++) {
		for(int j = i + 1; j <= n; j ++) {
			ans = min(ans, dis(xi[i], yi[i], xi[j], yi[j]));
		}
	}
	printf("%0.4f", sqrt(ans));
	return 0;
}