#include <bits/stdc++.h>
using namespace std;
#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int MAXN = 1e3+10, MOD = 1e9+7;
struct DSU {
vector<int> p, sz;
void init(int n){ p.resize(n); sz.assign(n, 1); iota(p.begin(), p.end(), 0); }
int find_set(int v){ return v==p[v]?v:p[v]=find_set(p[v]); }
bool union_sets(int a, int b){
if ((a=find_set(a))==(b=find_set(b))) return false;
if (sz[a] < sz[b]) swap(a, b);
p[b]=a, sz[a]+=sz[b], sz[b]=0;
return true;
}
} d;
int n;
ar<ll, 2> a[MAXN];
ar<ll, 3> e[MAXN*MAXN];
ll sq(ll x){ return x*x; }
ll dist(int i, int j) {
return sq(a[i][0]-a[j][0]) + sq(a[i][1]-a[j][1]);
}
void solve() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i][0] >> a[i][1];
int m = 0;
for (int i = 0; i < n; i++) for (int j = i+1; j < n; j++) {
e[m++] = {dist(i, j), i, j};
}
sort(e, e+m);
ll ans = 0;
d.init(n);
for (int i = 0; i < m; i++) if (d.union_sets(e[i][1], e[i][2])) ans = max(ans, e[i][0]);
cout << fixed << setprecision(7) << sqrtl(ans) / 2. << '\n';
}
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int T=1;
// cin >> T;
while (T--) solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 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 |
332 KB |
Output is correct |
6 |
Correct |
20 ms |
3148 KB |
Output is correct |
7 |
Correct |
24 ms |
3148 KB |
Output is correct |
8 |
Correct |
49 ms |
6860 KB |
Output is correct |
9 |
Correct |
75 ms |
12024 KB |
Output is correct |
10 |
Correct |
71 ms |
12056 KB |
Output is correct |