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<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<complex>
#include<map>
#include<iomanip>
using namespace std;
#define eps 1e-6
int n;
vector<pair<double, double>>balloons;
vector<double>res;
double dist(pair<double, double>a,pair<double,double>b){
return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
bool check(double mid, int indx){
for(int i = indx-1;i>=0;--i){
if(dist({balloons[i].first, res[i]},{balloons[indx].first, mid})-(res[i]+mid)< eps)return true;
}
return false;
}
int main(){
cin >> n;
balloons.resize(n);
for(int i = 0;i<n;++i){
cin >> balloons[i].first >> balloons[i].second;
}
res.resize(n);
res[0]=balloons[0].second;
for(int i = 1;i<n;++i){
double l = 1, r = balloons[i].second;
while(r-l>eps){
double mid = (l+r)/2;
if(check(mid, i)){
r = mid;
}
else l = mid;
}
res[i]=r;
}
for(double i : res)cout << fixed << setprecision(6)<< 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... |