Language: C++

#include<iostream>
#include<cmath>
#include<complex>
#include<vector>
#include<queue>
using namespace std;
#include<iostream>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)        (C).begin(),(C).end()
#define fir first
#define sec second
#define pb  push_back
#define mp  make_pair

typedef complex<double> P;

const double eps = 1e-10;

class DisjointSet{
public:
  vector<int> rank,p;
  DisjointSet(){}
  DisjointSet(int size){
    rank.resize(size,0);
    p.resize(size,0);
  }
  void make_set(int x){
    p[x]=x;
    rank[x]=0;
  }
  void merge(int x,int y){
    link(find_set(x),find_set(y));
  }
  void link(int x,int y){
    if (rank[x] > rank[y]){
      p[y]=x;
    }else {
      p[x]=y;
      if (rank[x] == rank[y])rank[y]+=1;
    }
  }
  int find_set(int x){
    if (x != p[x])p[x]=find_set(p[x]);
    return p[x];
  }
};

class Edge{
public:
  int f,t;
  double cost;
  bool operator<(const Edge& a)const{
    return cost < a.cost;
  }
};

double bsearch(P &a,P &va,P &b,P &vb,int t){
  double l=0,r=t;
  rep(i,100){
    double ls=l+(r-l)/3.,rs=l+(r-l)*2./3.;
    double dls=abs((a+ls*va)-(b+ls*vb));
    double drs=abs((a+rs*va)-(b+rs*vb));
    if (dls < drs){
      r=rs;
    }else{
      l=ls;
    }
  }
  return l;
}

double kruskal(vector<P> &a,vector<P> &v,double t){
  vector<P> in(a.size());
  vector<Edge> edge;
  DisjointSet dj(a.size());
  rep(i,a.size()){
    in[i]=a[i]+v[i]*t;
    dj.make_set(i);
  }
  
  rep(i,in.size()){
    REP(j,i+1,in.size()){
      edge.pb((Edge){i,j,abs(in[i]-in[j])});
    }
  }
  
  sort(ALL(edge));
  double ret=0;
  rep(i,edge.size()){
    if (dj.find_set(edge[i].f) != dj.find_set(edge[i].t)){
      dj.merge(edge[i].f,edge[i].t);
      ret+=edge[i].cost;  
    } 
  }
  return ret;
}

double solve(int t,vector<P> &pos,vector<P> &v){
  vector<double> cand;
  cand.pb(0);
  cand.pb(t);
  rep(i,pos.size()){
    REP(j,i+1,pos.size()){
      cand.pb(bsearch(pos[i],v[i],pos[j],v[j],t));
    }
  }
  sort(ALL(cand));
  cand.erase(unique(ALL(cand)),cand.end());
  double ret = 1e100;
  rep(i,cand.size()){
    ret=min(ret,kruskal(pos,v,cand[i]));
  }
  return ret;
}

main(){
  int n,t;
  while(cin>>n>>t && n){
    vector<P> pos(n),v(n);
    rep(i,n){
      double x,y;
      cin>>x>>y;pos[i]=P(x,y);
      cin>>x>>y;v[i]=P(x,y);
    }
    printf("%.10lf\n",solve(t,pos,v));
  }
  return false;
}

Compiler output:
a.cc: In function 'double kruskal(std::vector<std::complex<double> >&, std::vector<std::complex<double> >&, double)':
a.cc:90:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
   90 |   sort(ALL(edge));
      |   ^~~~
      |   sqrt
a.cc: In function 'double solve(int, std::vector<std::complex<double> >&, std::vector<std::complex<double> >&)':
a.cc:110:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
  110 |   sort(ALL(cand));
      |   ^~~~
      |   sqrt
a.cc:111:14: error: 'unique' was not declared in this scope
  111 |   cand.erase(unique(ALL(cand)),cand.end());
      |              ^~~~~~
a.cc: At global scope:
a.cc:119:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  119 | main(){
      | ^~~~