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;
using ll = long long;
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORU(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define IOS cin.tie(0)->sync_with_stdio(false);
#define PROB "BOI12_mobile"
void Fi(){
if(fopen(PROB".inp", "r")){
freopen(PROB".inp", "r", stdin);
freopen(PROB".out", "w", stdout);
}
}
double SQ(const double &x){
return x * x;
}
const ll NONE = -2e18;
ll Round(const double &x){
return (x * 1000 + 0.5);
}
double firstTrue(double lo, double hi, function<bool(double)> f){
while(Round(lo) < Round(hi)){
double mid = lo + (hi - lo) / 2;
if(f(mid)) hi = mid;
else lo = mid;
}
return hi;
}
int main(){
IOS;
Fi();
int n, l; cin >> n >> l;
vector<int> x(n), y(n);
FOR(i, 0, n) cin >> x[i] >> y[i];
const auto check = [&](const double &r) -> bool{
double L = NONE, R = NONE;
// vector<pair<double, double>> range;
FOR(i, 0, n) if(abs(y[i]) <= r){
double D = sqrt(SQ(r) - SQ(y[i]));
// range.eb(x[i] - D, x[i] + D);
if(L == NONE && R == NONE){
if(x[i] - D <= 0 && 0 <= x[i] + D){
L = x[i] - D;
R = x[i] + D;
}
} else{
L = min(L, x[i] - D);
if(x[i] - D <= R) R = max(R, x[i] + D);
}
}
// sort(ALL(range));
// double L = range[0].fi, R = range[0].se;
// FOR(i, 1, range.size()){
// if(range[i].fi <= R) R = max(R, range[i].se);
// }
return (L <= 0 && l <= R);
};
cout << fixed << setprecision(3) << firstTrue(0, 3e9, check);
return 0;
}
Compilation message (stderr)
mobile.cpp: In function 'void Fi()':
mobile.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | freopen(PROB".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | freopen(PROB".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |