fork(66) download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(){
  5. int c,n,m,i,j,t[100];
  6. float p[100][2],l[100],w,temp;
  7. scanf("%d",&c);
  8. while(c--){
  9. w=m=0;
  10. scanf("%d",&n);
  11. for(i=0;i<n;i++){
  12. scanf("%f%f",p[i],p[i]+1);
  13. t[i]=i;l[i]=9999999999;
  14. }
  15. l[0]=0;
  16. while(m<n){
  17. w=l[t[m]];
  18. for(i=0;i<=m;i++){
  19. for(j=m+1;j<n;j++){
  20. temp = pow(p[t[i]][0]-p[t[j]][0],2)+pow(p[t[i]][1]-p[t[j]][1],2);
  21. if(temp<l[t[j]]){
  22. l[t[j]]=temp;
  23. }
  24. if(l[t[j]]<=w){
  25. m++;
  26. temp=t[m];
  27. t[m]=t[j];
  28. t[j]=temp;
  29. }
  30. }
  31. }
  32. for(j=(++m)+1;j<n;j++){
  33. if(l[t[j]]<l[t[m]]){
  34. temp=t[m];
  35. t[m]=t[j];
  36. t[j]=temp;
  37. }
  38. }
  39. }
  40. printf("%.2f\n",(int)(sqrt(w)*100+0.5)/100.0);
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 2252KB
stdin
3
2
1000 1000
0 0
6
1.0 1.0
30.91 8
4.0 7.64
21.12 6.0
11.39 3.0
5.31 11.0
5
0 0
1 0
1 1
1 2
0 2
stdout
>w=0.00
>0,1 -> 2000000.00:0.00
>m=0
>w=2000000.00
>m=1
1414.21
>w=0.00
>0,1 -> 943.61:0.00
>0,2 -> 53.09:0.00
>0,3 -> 429.81:0.00
>0,4 -> 111.95:0.00
>0,5 -> 118.58:0.00
>m=0
>1,2 -> 53.09:0.00
>1,3 -> 429.81:0.00
>1,4 -> 111.95:0.00
>1,5 -> 118.58:0.00
>w=53.09
>0,2 -> 943.61:53.09
>0,3 -> 429.81:53.09
>0,4 -> 111.95:53.09
>0,5 -> 118.58:53.09
>1,2 -> 724.28:53.09
>1,3 -> 295.78:53.09
>1,4 -> 76.14:53.09
>1,5 -> 13.01:53.09
>2,3 -> 274.96:53.09
>2,4 -> 76.14:53.09
>2,5 -> 664.36:53.09
>m=2
>3,4 -> 76.14:53.09
>3,5 -> 664.36:53.09
>w=76.14
>0,4 -> 274.96:76.14
>0,5 -> 664.36:76.14
>1,4 -> 274.96:76.14
>1,5 -> 664.36:76.14
>2,4 -> 274.96:76.14
>2,5 -> 664.36:76.14
>3,4 -> 103.67:76.14
>3,5 -> 406.03:76.14
>m=3
>4,5 -> 406.03:76.14
>w=103.67
>0,5 -> 406.03:103.67
>1,5 -> 406.03:103.67
>2,5 -> 406.03:103.67
>3,5 -> 406.03:103.67
>4,5 -> 99.84:103.67
>m=5
10.18
>w=0.00
>0,1 -> 1.00:0.00
>0,2 -> 2.00:0.00
>0,3 -> 5.00:0.00
>0,4 -> 4.00:0.00
>m=0
>1,2 -> 2.00:0.00
>1,3 -> 5.00:0.00
>1,4 -> 4.00:0.00
>w=1.00
>0,2 -> 2.00:1.00
>0,3 -> 5.00:1.00
>0,4 -> 4.00:1.00
>1,2 -> 1.00:1.00
>1,3 -> 4.00:1.00
>1,4 -> 4.00:1.00
>2,3 -> 1.00:1.00
>2,4 -> 2.00:1.00
>3,4 -> 1.00:1.00
>m=4
1.00