# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1046837 | JohnnyVenturas | Mobile (BOI12_mobile) | C++17 | 455 ms | 8020 KiB |
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;
const int MAXN = 1e6;
pair<int, int> receivers[MAXN];
int last_true(int low, int high, function<bool(double)> f) {
--low;
for (int diff = high - low; diff > 0; diff /= 2) {
while (low + diff <= high && f(low + diff))
low += diff;
}
return low;
}
double first_true(double low, double high, function<bool(double)> f) {
--low, ++high;
double mid;
while (high - low > 1e-5) {
mid = low + (high - low) / 2;
if (f(mid)) {
high = mid;
} else {
low = mid;
}
}
return high;
}
bool intersect(pair<int, int> ¢er, double r, double L, double &left,
double &right) {
const auto &[x, y] = center;
double c = y;
double y0 = -c;
double d0 = abs(c);
left = -1 / 0., right = -1 / 0.;
if (d0 > r)
return false;
double d = sqrt(r * r - d0 * d0);
double m = d;
double ax = m, ay = y0;
double bx = -m, by = y0;
left = ax + x;
right = bx + x;
if(left > right) swap(left, right);
return true;
}
int main() {
int N, L;
cin >> N >> L;
for (int i = 0; i < N; ++i) {
cin >> receivers[i].first >> receivers[i].second;
}
cout << first_true(0.001, 1e9, [&](double r) {
double last_right = 0.0;
for (int i = 0; i < N; ++i) {
double left, right;
bool did_intersect = intersect(receivers[i], r, L, left, right);
if(!did_intersect) continue;
if(right < 0) continue;
if(left > last_right) continue;
last_right = max(last_right, right);
}
return last_right >= L;
}) << "\n";
}
Compilation message (stderr)
# | 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... |