#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int N=1e3+1;
int n,cnt;
bool f[N];
double x[N],y[N];
vector < int > v[N];
void Dfs(int x) {
++cnt;
f[x]=true;
for (int i=0; i<v[x].size(); i++) {
if (!f[v[x][i]]) Dfs(v[x][i]);
}
}
bool check(double d) {
cnt=0;
for (int i=1; i<=n; i++) {
v[i].clear();
f[i]=0;
}
for (int i=1; i<=n; i++)
for (int j=1; j<i; j++)
if (d*d>=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))
v[i].pb(j),v[j].pb(i);
Dfs(1);
return (cnt==n);
}
main () {
cin>>n;
for (int i=1; i<=n; i++) {
cin>>x[i]>>y[i];
}
double l=0,r=1e10,mid,res=-1;
for (int i=1; i<=200; i++) {
mid=(l+r)/2.0;
if (check(mid))
res=mid,r=mid-0.000001;
else
l=mid+0.000001;
}
res/=2.0;
printf("%.7f",res);
}
Compilation message
odasiljaci.cpp: In function 'void Dfs(int)':
odasiljaci.cpp:14:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i=0; i<v[x].size(); i++) {
| ~^~~~~~~~~~~~
odasiljaci.cpp: At global scope:
odasiljaci.cpp:35:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
35 | main () {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
400 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
2 ms |
364 KB |
Output is correct |
4 |
Correct |
5 ms |
364 KB |
Output is correct |
5 |
Correct |
6 ms |
364 KB |
Output is correct |
6 |
Correct |
130 ms |
1516 KB |
Output is correct |
7 |
Correct |
134 ms |
1420 KB |
Output is correct |
8 |
Correct |
285 ms |
3436 KB |
Output is correct |
9 |
Correct |
420 ms |
4480 KB |
Output is correct |
10 |
Correct |
373 ms |
4460 KB |
Output is correct |