Language: C++

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

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:14:3: error: reference to 'data' is ambiguous
   14 |   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:12:8: note:                 'struct data'
   12 | struct data{double x,y,z,r;};
      |        ^~~~
a.cc:18:13: error: expected ')' before 'd'
   18 |   State(data d, double t, int n):d(d),t(t),n(n){}
      |        ~    ^~
      |             )
a.cc:23:12: error: template argument 1 is invalid
   23 | vector<data> V;
      |            ^
a.cc:23:12: error: template argument 2 is invalid
a.cc: In function 'void init()':
a.cc:26:5: error: request for member 'clear' in 'V', which is of non-class type 'int'
   26 |   V.clear();
      |     ^~~~~
a.cc:27:5: error: request for member 'resize' in 'V', which is of non-class type 'int'
   27 |   V.resize(N);
      |     ^~~~~~
a.cc: In function 'void input()':
a.cc:33:13: error: invalid types 'int[int]' for array subscript
   33 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |             ^
a.cc:33:23: error: invalid types 'int[int]' for array subscript
   33 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |                       ^
a.cc:33:33: error: invalid types 'int[int]' for array subscript
   33 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |                                 ^
a.cc:33:43: error: invalid types 'int[int]' for array subscript
   33 |     cin >> V[i].x >> V[i].y >> V[i].z >> V[i].r;
      |                                           ^
a.cc: At global scope:
a.cc:37:15: error: reference to 'data' is ambiguous
   37 | 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:12:8: note:                 'struct data'
   12 | struct data{double x,y,z,r;};
      |        ^~~~
a.cc:37:24: error: reference to 'data' is ambiguous
   37 | 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:12:8: note:                 'struct data'
   12 | struct data{double x,y,z,r;};
      |        ^~~~
a.cc:37:31: error: expression list treated as compound expression in initializer [-fpermissive]
   37 | double getDis(data d1, data d2){
      |                               ^
a.cc: In function 'void solve()':
a.cc:42:17: error: invalid types 'int[int]' for array subscript
   42 |   Q.push(State(V[0],0,0));
      |                 ^
a.cc:55:35: error: 'struct State' has no member named 'd'
   55 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                   ^
a.cc:55:38: error: invalid types 'int[int]' for array subscript
   55 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                      ^
a.cc:55:41: error: 'getDis' cannot be used as a function
   55 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                         ^
a.cc:55:47: error: 'struct State' has no member named 'd'
   55 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                               ^
a.cc:55:52: error: invalid types 'int[int]' for array subscript
   55 |       double dis = max(getDis(now.d,V[i])-now.d.r-V[i].r,0.0);
      |                                                    ^
a.cc:56:34: error: invalid types 'int[int]' for array subscript
   56 |       if(!used[i]) Q.push(State(V[i],dis,i));
      |                                  ^