Submission #1056860

# Submission time Handle Problem Language Result Execution time Memory
1056860 2024-08-13T11:54:59 Z TimAni Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 31736 KB
// time-limit: 3000

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const double eps = 1e-4;

struct point {
    double x{}, y{};
};

void solve() {
    int n;
    double L; 
    cin >> n >> L;
    vector<point> p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    auto intersection = [&](const point& A, double R) -> array<double, 2> {
        // y^2 = 0, 
        // y^2 = R^2 - (x - A.x)^2 + 2yA.y - A.y ^ 2;
        // R^2 - (x - A.x) ^ 2 - A.y^2 = 0
        // R^2 - x^2 + 2xA.x - A.x^2 - A.y^2 = 0
        // x^2 - 2xA.x + A.x^2 + A.y^2 - R^2 = 0
        // D = -4A.y^2 + 4R^2
        if(abs(A.y) > R) {
            return {L, -1};
        }
        double D = R * R - A.y * A.y; // divided by 4
        double x1 = A.x - sqrt(D);
        double x2 = A.x + sqrt(D);
        if(x2 < x1) swap(x1, x2);
        if(x1 < 0) x1 = 0; 
        if(x2 > L) x2 = L;
        return {x1, x2};
    };

    auto good = [&](double R) {
        vector<array<double, 2>> segs(n);
        for(int i = 0; i < n; i++) {
            segs[i] = intersection(p[i], R);
        }
        sort(segs.begin(), segs.end());
        double l = segs[0][0], r = segs[0][1];
        int i = 0;
        while(i + 1 < n && segs[i + 1][0] <= r) {
            r = max(segs[i + 1][1], r);
            i++;
        }
        return r >= L && l <= 0;
    };

    double l = 0, r = 4e9;
    while(r - l > eps) {
        double R = (r + l) / 2;
        if(good(R)) {
            r = R;
        }
        else {
            l = R;
        }
        
    }
    cout << fixed << setprecision(-log10(eps)) << r << endl;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    double T = 1;
    //cin >> T;
    while(T--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 133 ms 2752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 182 ms 2904 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 156 ms 3160 KB Output is correct
2 Correct 182 ms 3292 KB Output is correct
3 Correct 214 ms 3092 KB Output is correct
4 Incorrect 302 ms 3412 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 190 ms 3416 KB Output is correct
2 Correct 237 ms 3416 KB Output is correct
3 Correct 224 ms 3576 KB Output is correct
4 Incorrect 326 ms 3408 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 179 ms 3560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1010 ms 16076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1030 ms 16072 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1036 ms 19120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 19120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1059 ms 22356 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 22352 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 25304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 25308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 31736 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1060 ms 31716 KB Time limit exceeded
2 Halted 0 ms 0 KB -