This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-6
int n;
vector<double>coor, radii, res;
double dist(pair<double, double>p1, pair<double, double>p2){
return sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second));
}
bool check(double mid, int indx){
for(int i = indx - 1;i >= 0;--i){
if(dist({coor[i], res[i]}, {coor[indx], mid}) - (mid + res[i]) < eps){
return true;
}
}
return false;
}
int main()
{
cin >> n;
coor.resize(n);
radii.resize(n);
res.resize(n);
for(int i = 0;i < n;++i){
cin >> coor[i] >> radii[i];
}
res[0] = radii[0];
for(int i = 1;i < n;++i){
double l = 0, r = radii[i];
while(r - l > eps){
double mid = (l + r)/ 2;
if(check(mid, i)){
r = mid;
}
else{
l = mid;
}
}
res[i] = l;
}
for(double i : res)cout << fixed << setprecision(4) << i << '\n';
}
# | 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... |