Language: C++

#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

#define REP(i, a, b) for(int i = (a); i < int(b); ++i)
#define rep(i, n) REP(i, 0, n)

constexpr double EPS = 1e-9;

struct point {
	double x, y, z;
	explicit point(double x_ = 0, double y_ = 0, double z_ = 0):x(x_), y(y_), z(z_) {}

	point operator-(const point &p) const {
		return point(x - p.x, y - p.y, z - p.z);
	}
};

struct sphere {
	point c;
	double r;
	sphere(const point &c_, double r_):c(c_), r(r_) {}
};

double norm(const point &p) {
  return p.x * p.x + p.y * p.y + p.z * p.z;
}

double dot(const point &a, const point &b) {
  return a.x * b.x + a.y * b.y + a.z * b.z;
}

vector<double> solve_quadratic_equation(double a, double b, double c) {
	const double d = b * b - 4 * a * c;
	if(d < -EPS) return {};
	return {(-b - sqrt(d)) / (2 * a), (-b + sqrt(d)) / (2 * a)};
}

double get_time(const sphere &a, const sphere &va, const sphere &b, const sphere &vb) {
	const point d = a.c - b.c;
	const point dv = va.c - vb.c;
	const double sum_r = a.r + b.r;
	const double sum_vr = va.r + vb.r;

	const double x = norm(dv) - sum_vr * sum_vr;
	const double y = 2.0 * (dot(d, dv) + sum_r * sum_vr);
	const double z = norm(d) - sum_r * sum_r;

	if(abs(x) < EPS) return INT_MAX;

	double res = INT_MAX;
	vector<double> ans = solve_quadratic_equation(x, y, z);
	for(const auto &e : ans) {
		if(e > 0) res = min(res, e);
	}
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(10);

	for(int n; cin >> n && n;) {
		vector<sphere> stars;
		vector<sphere> vec;
		stars.reserve(n);
		vec.reserve(n);

		rep(i, n) {
			double px, py, pz, vx, vy, vz, r, vr;
			cin >> px >> py >> pz >> vx >> vy >> vz >> r >> vr;
			stars.emplace_back(point(px, py, pz), r);
			vec.emplace_back(point(vx, vy, vz), vr);
		}

		typedef tuple<double, int, int> queue_t;
		priority_queue<queue_t, vector<queue_t>, greater<queue_t>> que;

		rep(i, n) {
			que.push({stars[i].r / vec[i].r, i, i});
		}

		rep(i, n) {
			rep(j, i) {
				que.push({get_time(stars[i], vec[i], stars[j], vec[j]), i, j});
			}
		}

		vector<double> ans(n);
		vector<bool> used(n, false);

		while(!que.empty()) {
			double t;
			int a, b;
			tie(t, a, b) = que.top();
			que.pop();

			if(used[a] || used[b]) continue;

			ans[a] = ans[b] = t;
			used[a] = used[b] = true;
		}

		for(const auto &e : ans) {
			cout << e << endl;
		}
	}
	return EXIT_SUCCESS;
}

Compiler output:
a.cc: In function 'double get_time(const sphere&, const sphere&, const sphere&, const sphere&)':
a.cc:52:33: error: 'INT_MAX' was not declared in this scope
   52 |         if(abs(x) < EPS) return INT_MAX;
      |                                 ^~~~~~~
a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <queue>
  +++ |+#include <climits>
    5 | #include <vector>
a.cc:54:22: error: 'INT_MAX' was not declared in this scope
   54 |         double res = INT_MAX;
      |                      ^~~~~~~
a.cc:54:22: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'