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>
#define name "cownav"
#define fi(i,a,b) for(int i = a; i <= b; i++)
#define fid(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define f first
#define se second
#define pii pair<int, int>
#define getbit(i, j) ((i >> j) & 1)
#define pb push_back
#define all(v) v.begin(), v.end()
#define maxn 200005
const int M = 1e9 + 7;
using namespace std;
int n, x[maxn], top, q[maxn];
double r[maxn];
void sub1(){
fi(i, 2, n){
fi(j, 1, i - 1){
ll A = 1ll*(x[i] - x[j])*(x[i] - x[j]);
double _r = A/(4*r[j]);
r[i] = min(r[i], _r);
}
}
fi(i, 1, n) cout << fixed << setprecision(3) << r[i] << '\n';
exit(0);
}
double radius(int a, int b, double c){
ll A = 1ll*(a - b)*(a - b);
return A/(4*c);
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
// freopen(name".in", "r", stdin);
// freopen(name".out", "w", stdout);
cin >> n;
fi(i, 1, n) cin >> x[i] >> r[i];
if(n <= 2000) sub1();
top = 1; q[1] = 1;
fi(i, 2, n){
while(top > 0){
r[i] = min(r[i], radius(x[q[top]], x[i], r[q[top]]));
if(r[i] >= r[q[top]])top--;
else break;
}
q[++top] = i;
}
fi(i, 1, n) cout << fixed << setprecision(3) << r[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... |