# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
904174 | vjudge1 | Odašiljači (COCI20_odasiljaci) | C++17 | 125 ms | 456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define repf(i,k,n) for(int i=k; i<n; i++)
#define rep(i,n) for(int i=0; i<n; i++)
typedef vector<int> vi;
struct DSU{
vi p,size;
DSU(int n){
p.resize(n);
rep(i,n) p[i]=i;
size.assign(n,1);
};
int find(int x){
return (x==p[x] ? x : p[x]=find(p[x]));
}
void join(int a, int b){
int x=find(a), y=find(b);
if(x==y) return;
if(size[x]<size[y]) swap(x,y);
p[x]=y;
size[y]+=size[x];
}
bool isSame(int a, int b){
return find(a)==find(b);
}
int sz(int x){
return size[find(x)];
}
};
bool check(vi &x, vi &y, double r){
int n=x.size();
DSU dsu(n);
rep(i,n){
rep(j,n){
double a=(x[i]-x[j]),
b=(y[i]-y[j]);
if(a*a+b*b<=4*r*r) dsu.join(i,j);
}
}
return dsu.sz(0)==n;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int n; cin>>n;
vi x(n), y(n);
rep(i,n) cin>>x[i]>>y[i];
cout << setprecision(7);
double l=0, r=1e9, e=1e-7;
while(l+e<r){
double m=(l+r)/2;
//cerr << m << '\n';
if(check(x,y,m))
r=m;
else
l=m+e;
}
cout << l << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |