이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |