#include<algorithm>
#include<cmath>
#include<cstdio>
int read(){
bool flag=true;
int ch=getchar(),num=0;
while(ch<48||ch>57){
if(ch=='-')flag=false;
ch=getchar();
}
while(ch>=48&&ch<=57)num=(num<<3)+(num<<1)+(ch^48),ch=getchar();
return flag?num:-num;
}
long long abs(long long a){
return a>=0ll?a:-a;
}
const int maxn=1005;
int n,x[maxn],y[maxn];
int total;
struct Edge{
int u,v;
long long dis;
}e[maxn*maxn>>1];
bool operator<(Edge a,Edge b){
return a.dis<b.dis;
}
int fa[maxn];
int find(int x){
return x==fa[x]?x:find(fa[x]);
}
int main(){
n=read();
register int i,j,cnt=0,fu,fv;
register long long xdis,ydis,answer;
for(i=1;i<=n;i++){
x[i]=read(),y[i]=read();
for(j=1;j<i;j++){
xdis=abs(x[i]-x[j]);
ydis=abs(y[i]-y[j]);
e[++total]=Edge{j,i,xdis*xdis+ydis*ydis};
}
}
std::sort(e+1,e+total+1);
for(i=1;i<=n;i++)fa[i]=i;
for(i=1;i<=total;i++){
fu=find(e[i].u),fv=find(e[i].v);
if(fu==fv)continue;
fa[fu]=fv;
cnt++;
if(cnt==n-1){
answer=e[i].dis;
break;
}
}
printf("%.9lf",sqrt((double)answer/(double)4.0));
return 0;
}
Compilation message
odasiljaci.cpp: In function 'int main()':
odasiljaci.cpp:55:22: warning: 'answer' may be used uninitialized in this function [-Wmaybe-uninitialized]
55 | printf("%.9lf",sqrt((double)answer/(double)4.0));
| ^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
620 KB |
Output is correct |
6 |
Correct |
6 ms |
3760 KB |
Output is correct |
7 |
Correct |
7 ms |
3672 KB |
Output is correct |
8 |
Correct |
17 ms |
5720 KB |
Output is correct |
9 |
Correct |
38 ms |
8028 KB |
Output is correct |
10 |
Correct |
37 ms |
8024 KB |
Output is correct |