#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3cSpNGp ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
struct dsu{
int n,size_;
vector<int> par,siz,color;
dsu(int m){
init(m);
}
void init(int m){
n=m; size_=m;
par.resize(n,0);siz.resize(n,0);color.resize(n,0);
for(int i=0;i<n;i++){
par[i]=i; siz[i]=1;
}
}
void merge(int x,int y,int type=0){
int a=parent(x),b=parent(y);
if(a==b) return;
size_--;
if(siz[a]>siz[b]) {
siz[a]+=siz[b];
par[b]=a;
}else{
siz[b]+=siz[a];
par[a]=b;
}
}
int parent(int x){
return par[x]==x?x:parent(par[x]);
}
bool same(int x, int y){
return parent(x)==parent(y);
}
int size(){
return size_;
}
};
ld qu(ld d){
return d*d;
}
int main(){
_3cSpNGp;
int n;
cin>>n;
vec(pii) a(n);
rep(i,n){
cin>>a[i].fi>>a[i].se;
}
auto f=[&](ld rad)->bool{
dsu uf(n);
rep(i,n){
crep(j,i+1,n){
ld dist=qu(a[i].fi-a[j].fi)+qu(a[i].se-a[j].se);
if(dist<=qu(2*rad)){
uf.merge(i,j);
}
}
}
return uf.size()==1;
};
ld l=0,r=1e10,c=-1;
rep(_,300){
ld m=(l+r)/2;
if(f(m)){
c=m;
r=m;
}else{
l=m;
}
}
cout<<fixed<<setprecision(8);
cout<<c<<"\n";
//
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Correct |
8 ms |
224 KB |
Output is correct |
6 |
Correct |
115 ms |
308 KB |
Output is correct |
7 |
Correct |
119 ms |
304 KB |
Output is correct |
8 |
Correct |
249 ms |
336 KB |
Output is correct |
9 |
Correct |
379 ms |
336 KB |
Output is correct |
10 |
Correct |
423 ms |
340 KB |
Output is correct |