Language: C++

#include<iostream>
#include<vector>
#include<queue>
#include<cmath>

using namespace std;

const int MAX = 101;
bool used[MAX];

struct data{double x,y,z,r;};
struct State{
  data d;
  double t;
  int n;
  State(){}
  State(data d, double t, int n):d(d),t(t),n(n){}
  bool operator < (const State& s) const {return t > s.t;}
};

int N;
vector<data> V;

void init(){
  V.clear();
  V.resize(N);
  fill(used,used+MAX,false);
}

void input(){
  for(int i = 0; i < N; i++)
    cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
}


double getDis(data d1, data d2){
  return sqrt(pow(d1.x-d2.x,2.0)+pow(d1.y-d2.y,2.0)+pow(d1.z-d2.z,2.0));
}
void solve(){
  priority_queue<State> Q;
  Q.push(State(V[0],0,0));
  
  double ans = 0;
  while(!Q.empty()){
    State now = Q.top();
    Q.pop();
    
    if(used[now.n]) continue;
    used[now.n] = true;
  
    ans += now.t;
    
    for(int i = 0; i < N; i++){
      double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      if(!used[i]) Q.push(State(V[i],dis,i));
    }
  }
  printf("%.3f\n",ans);
}

int main(){
  while(cin >> N && N){
    init();
    input();
    solve();
  }
  return 0;
}

Compiler output:
a.cc:13:3: error: reference to 'data' is ambiguous
   13 |   data d;
      |   ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:8: note:                 'struct data'
   11 | struct data{double x,y,z,r;};
      |        ^~~~
a.cc:17:13: error: expected ')' before 'd'
   17 |   State(data d, double t, int n):d(d),t(t),n(n){}
      |        ~    ^~
      |             )
a.cc:22:12: error: template argument 1 is invalid
   22 | vector<data> V;
      |            ^
a.cc:22:12: error: template argument 2 is invalid
a.cc: In function 'void init()':
a.cc:25:5: error: request for member 'clear' in 'V', which is of non-class type 'int'
   25 |   V.clear();
      |     ^~~~~
a.cc:26:5: error: request for member 'resize' in 'V', which is of non-class type 'int'
   26 |   V.resize(N);
      |     ^~~~~~
a.cc: In function 'void input()':
a.cc:32:13: error: invalid types 'int[int]' for array subscript
   32 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |             ^
a.cc:32:23: error: invalid types 'int[int]' for array subscript
   32 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |                       ^
a.cc:32:33: error: invalid types 'int[int]' for array subscript
   32 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |                                 ^
a.cc:32:43: error: invalid types 'int[int]' for array subscript
   32 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |                                           ^
a.cc: At global scope:
a.cc:36:15: error: reference to 'data' is ambiguous
   36 | double getDis(data d1, data d2){
      |               ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:8: note:                 'struct data'
   11 | struct data{double x,y,z,r;};
      |        ^~~~
a.cc:36:24: error: reference to 'data' is ambiguous
   36 | double getDis(data d1, data d2){
      |                        ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:11:8: note:                 'struct data'
   11 | struct data{double x,y,z,r;};
      |        ^~~~
a.cc:36:31: error: expression list treated as compound expression in initializer [-fpermissive]
   36 | double getDis(data d1, data d2){
      |                               ^
a.cc: In function 'void solve()':
a.cc:41:17: error: invalid types 'int[int]' for array subscript
   41 |   Q.push(State(V[0],0,0));
      |                 ^
a.cc:54:35: error: 'struct State' has no member named 'd'
   54 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                   ^
a.cc:54:38: error: invalid types 'int[int]' for array subscript
   54 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                      ^
a.cc:54:41: error: 'getDis' cannot be used as a function
   54 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                         ^
a.cc:54:47: error: 'struct State' has no member named 'd'
   54 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                               ^
a.cc:54:52: error: invalid types 'int[int]' for array subscript
   54 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                                    ^
a.cc:55:34: error: invalid types 'int[int]' for array subscript
   55 |       if(!used[i]) Q.push(State(V[i],dis,i));
      |                                  ^