#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);
}
Compilation message
odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:75:16: warning: use of 'll' length modifier with 'f' type character has either no effect or undefined behavior [-Wformat=]
75 | printf("%.7llf\n",r);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Incorrect |
5 ms |
364 KB |
Output isn't correct |
4 |
Correct |
9 ms |
492 KB |
Output is correct |
5 |
Correct |
34 ms |
364 KB |
Output is correct |
6 |
Incorrect |
439 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
341 ms |
492 KB |
Output isn't correct |
8 |
Execution timed out |
1080 ms |
364 KB |
Time limit exceeded |
9 |
Execution timed out |
1088 ms |
364 KB |
Time limit exceeded |
10 |
Execution timed out |
1093 ms |
364 KB |
Time limit exceeded |