Submission #1056961

# Submission time Handle Problem Language Result Execution time Memory
1056961 2024-08-13T12:44:06 Z TimAni Mobile (BOI12_mobile) C++17
0 / 100
371 ms 23932 KB
// time-limit: 3000
 
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
const double eps = 1e-6;
 
struct point {
    int x{}, y{};
};
 
void solve() {
    int n, 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> {
        if(abs(A.y) > R) {
            return {L + 2, -2};
        }
        double D = 1.0 * R * R - 1.0 * 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 = -1; 
        if(x2 > L) x2 = L + 1;
        if(x2 < 0 || x1 > L)
            return {L + 2, -2};
        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);
        }
        double r = segs[0][1], l = segs[0][0];
        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;
}

Compilation message

mobile.cpp: In lambda function:
mobile.cpp:23:23: warning: narrowing conversion of '(L + 2)' from 'int' to 'double' [-Wnarrowing]
   23 |             return {L + 2, -2};
      |                     ~~^~~
mobile.cpp:32:23: warning: narrowing conversion of '(L + 2)' from 'int' to 'double' [-Wnarrowing]
   32 |             return {L + 2, -2};
      |                     ~~^~~
# 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 0 ms 348 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 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 2224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 2196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 2396 KB Output is correct
2 Incorrect 34 ms 2400 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 12172 KB Output is correct
2 Correct 182 ms 12176 KB Output is correct
3 Correct 173 ms 12188 KB Output is correct
4 Incorrect 201 ms 12112 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 195 ms 12188 KB Output is correct
2 Incorrect 162 ms 12116 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 204 ms 14468 KB Output is correct
2 Incorrect 216 ms 14540 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 213 ms 14472 KB Output is correct
2 Incorrect 210 ms 14516 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 234 ms 16792 KB Output is correct
2 Incorrect 251 ms 16788 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 259 ms 16792 KB Output is correct
2 Incorrect 266 ms 16892 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 262 ms 19232 KB Output is correct
2 Incorrect 320 ms 19048 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 305 ms 19292 KB Output is correct
2 Incorrect 286 ms 19324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 318 ms 23892 KB Output is correct
2 Incorrect 361 ms 23888 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 371 ms 23932 KB Output is correct
2 Incorrect 337 ms 23908 KB Output isn't correct
3 Halted 0 ms 0 KB -