#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1007;
struct Edge{
int u, v;
ll c;
Edge(int _u, int _v, ll _c){
u = _u;
v = _v;
c = _c;
}
bool operator < (const Edge &oth){
return c < oth.c;
}
};
struct Dsu{
int root[N], rnk[N];
void init(int n){
for(int i = 1; i <= n; i++){
root[i] = i;
rnk[i] = 0;
}
}
int findRoot(int u){
if (u == root[u])
return u;
return root[u] = findRoot(root[u]);
}
bool unite(int u, int v){
u = findRoot(u);
v = findRoot(v);
if (u == v)
return 0;
if (rnk[u] < rnk[v])
swap(u, v);
root[v] = u;
rnk[u] += (rnk[u] == rnk[v]);
return 1;
}
};
int n, x[N], y[N];
vector<Edge> edges;
Dsu dsu;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; i++)
cin >> x[i] >> y[i];
for(int i = 1; i <= n; i++)
for(int j = i + 1; j <= n; j++){
ll c = (ll) (x[i] - x[j]) * (x[i] - x[j]) + (ll) (y[i] - y[j]) * (y[i] - y[j]);
edges.push_back(Edge(i, j, c));
}
sort(edges.begin(), edges.end());
int cnt = 0;
dsu.init(n);
for(Edge e : edges){
cnt += dsu.unite(e.u, e.v);
if (cnt == n - 1){
cout << fixed << setprecision(9) << sqrt(e.c) / 2;
return 0;
}
}
cout << 0;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
460 KB |
Output is correct |
6 |
Correct |
10 ms |
2496 KB |
Output is correct |
7 |
Correct |
11 ms |
2504 KB |
Output is correct |
8 |
Correct |
25 ms |
8640 KB |
Output is correct |
9 |
Correct |
55 ms |
8640 KB |
Output is correct |
10 |
Correct |
55 ms |
8640 KB |
Output is correct |