# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
332186 | DanerZein | Odašiljači (COCI20_odasiljaci) | C++14 | 1093 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
const ll MAX=1e9;
int ns;
double raiz(ll x){
double l=0,r=MAX;
for(int i=0;i<=40;i++){
double mid=(l+r)/2;
if(mid*mid>=x)r=mid;
else l=mid;
}
return r;
}
int pa[1010];
void init(int n){
for(int i=0;i<n;i++) pa[i]=i;
ns=n;
}
int findset(int i){
if(pa[i]==i) return pa[i];
return pa[i]=findset(pa[i]);
}
bool issameset(int i,int j){
return findset(i)==findset(j);
}
void unionset(int i,int j){
if(!issameset(i,j)){
int x=findset(i),y=findset(j);
ns--;
pa[x]=y;;
}
}
vector<ii> x;
bool check(double r,int n){
init(n);
//cout<<r<<endl;
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
if(!issameset(i,j)){
double a=abs(x[i].first-x[j].first);
double b=abs(x[i].second-x[j].second);
double dist=raiz((a*a)+(b*b));
dist/=2;
// cout<<i<<" "<<j<<" "<<dist<<" "<<r<<" "<<ns<<endl;
if(dist<=r) unionset(i,j);
}
}
}
if(ns==1) return true;
return false;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
for(int i=0;i<n;i++){
int a,b;
cin>>a>>b;
x.push_back(ii(a,b));
}
ld l=0,r=MAX;
for(int i=0;i<=60;i++){
ld mid=(l+r)/2;
if(check(mid,n)){
r=mid;
}
else l=mid;
//break;
}
printf("%.7llf\n",r);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |