比赛 |
20161223 |
评测结果 |
AAAAAAAAAA |
题目名称 |
哞投 |
最终得分 |
100 |
用户昵称 |
KZNS |
运行时间 |
0.236 s |
代码语言 |
C++ |
内存使用 |
0.29 MiB |
提交时间 |
2016-12-23 20:13:17 |
显示代码纯文本
//KZNS
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
#define Nmax 1003
inline int diss(int a, int b, int c, int d) {
return (a-c)*(a-c) + (b-d)*(b-d);
}
typedef pair<int, pair<int, int> > pr;
int N;
int A[Nmax][2];
vector<pr> ls;
void init() {
scanf("%d", &N);
for (int i = 1; i <= N; i++) {
scanf("%d %d", &A[i][0], &A[i][1]);
for (int j = 1; j < i; j++)
ls.push_back(make_pair(diss(A[j][0], A[j][1], A[i][0], A[i][1]), make_pair(i, j)));
}
}
int fa[Nmax];
int FA(int x) {
if (fa[x] == x)
return x;
return fa[x] = FA(fa[x]);
}
void sb(int a, int b) {
if (FA(a) != FA(b)) {
fa[fa[a]] = fa[b];
N--;
}
}
void work() {
sort(ls.begin(), ls.end());
for (int i = 1; i <= N; i++)
fa[i] = i;
pr u;
for (int i = 0; i < ls.size(); i++) {
u = ls[i];
sb(u.second.first, u.second.second);
if (N <= 1) {
printf("%d\n", u.first);
return;
}
}
}
int main() {
freopen("moocast.in", "r", stdin);
freopen("moocast.out", "w", stdout);
init();
work();
return 0;
}
//UBWH