#include <bits/stdc++.h>
// #pragma GCC target ("avx,avx2,fma")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define f first
#define s second
using namespace std;
double dist(pair<double, double> a, pair<double, double> b)
{
return sqrt(abs(a.f - b.f) * abs(a.f - b.f) + abs(a.s - b.s) * abs(a.s - b.s));
}
bool touch(pair<double, double> a, pair<double, double> b)
{
double d = dist(a, b);
// cout << d << ' ' << a.s + b.s << endl;
return d <= (a.s + b.s);
}
void solve(int tc)
{
int n;
cin >> n;
vector<pair<double, double>> points(n);
for (int i = 0; i < n; i++)
cin >> points[i].f >> points[i].s;
sort(all(points));
vector<pair<double, double>> st;
for (int i = 0; i < n; i++)
{
double rad = INT_MAX;
while (st.size())
{
pair<double, double> cur = st.back();
double eps = 1e-10;
double l = eps, r = points[i].s;
double best = eps;
while (l + eps < r)
{
double mid = (l + r) / 2;
if (!touch(cur, {points[i].f, mid}))
{
l = mid + eps;
best = mid;
}
else r = mid - eps;
}
rad = min(best, rad);
if (best > cur.s)
{
st.pop_back();
}
else
{
break;
}
}
rad = min(rad, points[i].s);
cout << rad << endl;
st.push_back({points[i].f, rad});
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
for (int i = 1; i <= t; i++)
{
solve(i);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |